Search in sources :

Example 46 with Search

use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.

the class ImplicitSearchFieldsTestCase method testRequireThatSummaryFieldsAreIncluded.

@Test
public void testRequireThatSummaryFieldsAreIncluded() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/summaryfield.sd");
    assertNotNull(search);
    SDDocumentType docType = search.getDocument();
    assertNotNull(docType);
    assertNotNull(docType.getField("rankfeatures"));
    assertNotNull(docType.getField("summaryfeatures"));
    assertNotNull(docType.getField("foo"));
    assertNotNull(docType.getField("bar"));
    assertNotNull(docType.getField("cox"));
    assertEquals(5, docType.getFieldCount());
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 47 with Search

use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.

the class ImplicitSearchFieldsTestCase method testRequireThatBoldedSummaryFieldsAreIncluded.

@Test
public void testRequireThatBoldedSummaryFieldsAreIncluded() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/boldedsummaryfields.sd");
    assertNotNull(search);
    SDDocumentType docType = search.getDocument();
    assertNotNull(docType);
    assertNotNull(docType.getField("rankfeatures"));
    assertNotNull(docType.getField("summaryfeatures"));
    assertNotNull(docType.getField("foo"));
    assertNotNull(docType.getField("bar"));
    assertNotNull(docType.getField("baz"));
    assertNotNull(docType.getField("cox"));
    assertEquals(6, docType.getFieldCount());
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 48 with Search

use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.

the class ImplicitSummariesTestCase method requireThatSummaryFromAttributeDoesNotWarn.

@Test
public void requireThatSummaryFromAttributeDoesNotWarn() throws IOException, ParseException {
    LogHandler log = new LogHandler();
    Logger.getLogger("").addHandler(log);
    Search search = SearchBuilder.buildFromFile("src/test/examples/implicitsummaries_attribute.sd");
    assertNotNull(search);
    assertTrue(log.records.isEmpty());
}
Also used : Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 49 with Search

use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.

the class NGramTestCase method testInvalidNGramSetting3.

@Test
public void testInvalidNGramSetting3() throws IOException, ParseException {
    try {
        Search search = SearchBuilder.buildFromFile("src/test/examples/invalidngram3.sd");
        fail("Should cause an exception");
    } catch (IllegalArgumentException e) {
        assertEquals("gram matching is not supported with attributes, use 'index' not 'attribute' in indexing", e.getMessage());
    }
}
Also used : Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 50 with Search

use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.

the class NGramTestCase method testNGram.

@Test
public void testNGram() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/ngram.sd");
    assertNotNull(search);
    SDField gram1 = search.getConcreteField("gram_1");
    assertEquals(Matching.Type.GRAM, gram1.getMatching().getType());
    assertEquals(1, gram1.getMatching().getGramSize());
    SDField gram2 = search.getConcreteField("gram_2");
    assertEquals(Matching.Type.GRAM, gram2.getMatching().getType());
    // Not set explicitly
    assertEquals(-1, gram2.getMatching().getGramSize());
    SDField gram3 = search.getConcreteField("gram_3");
    assertEquals(Matching.Type.GRAM, gram3.getMatching().getType());
    assertEquals(3, gram3.getMatching().getGramSize());
    assertEquals("input gram_1 | ngram 1 | index gram_1 | summary gram_1", gram1.getIndexingScript().iterator().next().toString());
    assertEquals("input gram_2 | ngram 2 | index gram_2", gram2.getIndexingScript().iterator().next().toString());
    assertEquals("input gram_3 | ngram 3 | index gram_3", gram3.getIndexingScript().iterator().next().toString());
    assertFalse(gram1.getNormalizing().doRemoveAccents());
    assertEquals(Stemming.NONE, gram1.getStemming());
    List<String> queryCommands = gram1.getQueryCommands();
    assertEquals(1, queryCommands.size());
    assertEquals("ngram 1", queryCommands.get(0));
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Search(com.yahoo.searchdefinition.Search) 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