use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class SearchOrderer method order.
/**
* Reorders the given list of search definitions such that any supertype
* always preceed any subtype. Subject to this condition the given order
* is preserved (the minimal reordering is done).
*
* @return a new list containing the same search instances in the right order
*/
public List<Search> order(List<Search> unordered) {
// Description above state that the original order should be preserved, except for the dependency constraint.
// Yet we botch that guarantee by sorting the list...
unordered.sort(Comparator.comparing(Search::getName));
// No, this is not a fast algorithm...
indexOnDocumentName(unordered);
List<Search> ordered = new ArrayList<>(unordered.size());
List<Search> moveOutwards = new ArrayList<>();
for (Search search : unordered) {
if (allDependenciesAlreadyEmitted(ordered, search)) {
addOrdered(ordered, search, moveOutwards);
} else {
moveOutwards.add(search);
}
}
// Any leftovers means we have search definitions with undefined inheritants.
// This is warned about elsewhere.
ordered.addAll(moveOutwards);
documentNameToSearch.clear();
return ordered;
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class SearchOrderer method addOrdered.
private void addOrdered(List<Search> ordered, Search search, List<Search> moveOutwards) {
ordered.add(search);
Search eligibleMove;
do {
eligibleMove = removeFirstEntryWithFullyEmittedDependencies(moveOutwards, ordered);
if (eligibleMove != null) {
ordered.add(eligibleMove);
}
} while (eligibleMove != null);
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class AddAttributeTransformToSummaryOfImportedFieldsTest method createSearchWithDocument.
private static Search createSearchWithDocument(String documentName) {
Search search = new Search(documentName, MockApplicationPackage.createEmpty());
SDDocumentType document = new SDDocumentType(documentName, search);
search.addDocument(document);
return search;
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class AddAttributeTransformToSummaryOfImportedFieldsTest method attribute_summary_transform_applied_to_summary_field_of_imported_field.
@Test
public void attribute_summary_transform_applied_to_summary_field_of_imported_field() {
Search search = createSearchWithDocument(DOCUMENT_NAME);
search.setImportedFields(createSingleImportedField(IMPORTED_FIELD_NAME));
search.addSummary(createDocumentSummary(IMPORTED_FIELD_NAME));
AddAttributeTransformToSummaryOfImportedFields processor = new AddAttributeTransformToSummaryOfImportedFields(search, null, null, null);
processor.process(true);
SummaryField summaryField = search.getSummaries().get(SUMMARY_NAME).getSummaryField(IMPORTED_FIELD_NAME);
SummaryTransform actualTransform = summaryField.getTransform();
assertEquals(SummaryTransform.ATTRIBUTE, actualTransform);
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class BoldingTestCase method testBoldingNonString.
@Test
public void testBoldingNonString() throws IOException, ParseException {
try {
Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/processing/boldnonstring.sd");
new Bolding(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
fail();
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("'bolding: on' for non-text field"));
}
}
Aggregations