Search in sources :

Example 1 with Search

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;
}
Also used : Search(com.yahoo.searchdefinition.Search)

Example 2 with Search

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);
}
Also used : Search(com.yahoo.searchdefinition.Search)

Example 3 with Search

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;
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search)

Example 4 with 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);
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) Search(com.yahoo.searchdefinition.Search) SummaryTransform(com.yahoo.vespa.documentmodel.SummaryTransform) Test(org.junit.Test)

Example 5 with Search

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"));
    }
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) Test(org.junit.Test)

Aggregations

Search (com.yahoo.searchdefinition.Search)62 Test (org.junit.Test)47 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)21 SDField (com.yahoo.searchdefinition.document.SDField)15 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)13 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)12 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)8 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)8 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)6 File (java.io.File)5 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)4 RankProfile (com.yahoo.searchdefinition.RankProfile)3 Field (com.yahoo.document.Field)2 StructDataType (com.yahoo.document.StructDataType)2 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)2 DocumentReference (com.yahoo.searchdefinition.DocumentReference)2 Index (com.yahoo.searchdefinition.Index)2 UnprocessingSearchBuilder (com.yahoo.searchdefinition.UnprocessingSearchBuilder)2 Attribute (com.yahoo.searchdefinition.document.Attribute)2 ImportedField (com.yahoo.searchdefinition.document.ImportedField)2