Search in sources :

Example 16 with QueryProfiles

use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.

the class TypeConversionTestCase method testExactStringToStringTypeConversion.

/**
 * Tests that exact-string stuff is not spilled over to the default index
 */
@Test
public void testExactStringToStringTypeConversion() {
    Search search = new Search("test", null);
    RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
    SDDocumentType document = new SDDocumentType("test");
    search.addDocument(document);
    SDField a = new SDField("a", DataType.STRING);
    a.parseIndexingScript("{ index }");
    document.addField(a);
    Processing.process(search, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles(), true);
    DerivedConfiguration derived = new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
    IndexInfo indexInfo = derived.getIndexInfo();
    assertFalse(indexInfo.hasCommand("default", "compact-to-term"));
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) Test(org.junit.Test)

Example 17 with QueryProfiles

use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.

the class QueryProfileVariantsTestCase method testConfigCreation2.

@Test
public void testConfigCreation2() throws IOException {
    QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/vespa/model/container/search/test/queryprofilevariants2");
    QueryProfiles profiles = new QueryProfiles(registry);
    assertSerializedConfigFileEquals(root + "query-profile-variants2-configuration.cfg", profiles.getConfig().toString());
}
Also used : QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 18 with QueryProfiles

use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.

the class AttributePropertiesTestCase method testInvalidAttributeProperties.

@Test
public void testInvalidAttributeProperties() throws IOException, ParseException {
    try {
        Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/attributeproperties1.sd");
        new AttributeProperties(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
        fail("attribute property should not be set");
    } catch (RuntimeException e) {
    // empty
    }
}
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)

Example 19 with QueryProfiles

use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.

the class AttributePropertiesTestCase method testValidAttributeProperties.

@Test
public void testValidAttributeProperties() throws IOException, ParseException {
    Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/attributeproperties2.sd");
    new AttributeProperties(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
}
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)

Example 20 with QueryProfiles

use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.

the class SearchImporterTestCase method testSimpleImporting.

@Test
public void testSimpleImporting() throws IOException, ParseException {
    RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
    SearchBuilder sb = new UnprocessingSearchBuilder(rankProfileRegistry, new QueryProfileRegistry());
    sb.importFile("src/test/examples/simple.sd");
    sb.build();
    Search search = sb.getSearch();
    assertEquals("simple", search.getName());
    assertTrue(search.hasDocument());
    SDDocumentType document = search.getDocument();
    assertEquals("simple", document.getName());
    assertEquals(12, document.getFieldCount());
    SDField field;
    Attribute attribute;
    new MakeAliases(search, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles()).process(true);
    // First field
    field = (SDField) document.getField("title");
    assertEquals(DataType.STRING, field.getDataType());
    assertEquals("{ summary | index; }", field.getIndexingScript().toString());
    assertTrue(!search.getIndex("default").isPrefix());
    assertTrue(search.getIndex("title").isPrefix());
    Iterator<String> titleAliases = search.getIndex("title").aliasIterator();
    assertEquals("aliaz", titleAliases.next());
    assertEquals("analias.totitle", titleAliases.next());
    assertEquals("analias.todefault", search.getIndex("default").aliasIterator().next());
    assertEquals(RankType.IDENTITY, field.getRankType());
    assertTrue(field.getAttributes().size() == 0);
    assertNull(field.getStemming());
    assertTrue(field.getNormalizing().doRemoveAccents());
    assertTrue(field.isHeader());
    // Second field
    field = (SDField) document.getField("description");
    assertEquals(RankType.ABOUT, field.getRankType());
    assertEquals(SummaryTransform.NONE, field.getSummaryField("description").getTransform());
    assertEquals(SummaryTransform.DYNAMICTEASER, field.getSummaryField("dyndesc").getTransform());
    assertNull(field.getStemming());
    assertTrue(field.getNormalizing().doRemoveAccents());
    assertEquals("hallo", search.getIndex("description").aliasIterator().next());
    // Third field
    field = (SDField) document.getField("chatter");
    assertEquals(RankType.ABOUT, field.getRankType());
    assertNull(field.getStemming());
    assertTrue(field.getNormalizing().doRemoveAccents());
    // Fourth field
    field = (SDField) document.getField("category");
    assertEquals(0, field.getAttributes().size());
    assertEquals(Stemming.NONE, field.getStemming());
    assertTrue(!field.getNormalizing().doRemoveAccents());
    // Fifth field
    field = (SDField) document.getField("popularity");
    assertEquals("{ attribute; }", field.getIndexingScript().toString());
    // Sixth field
    field = (SDField) document.getField("measurement");
    assertEquals(DataType.INT, field.getDataType());
    assertEquals(RankType.EMPTY, field.getRankType());
    assertEquals(1, field.getAttributes().size());
    // Seventh field
    field = search.getConcreteField("categories");
    assertEquals("{ input categories_src | lowercase | normalize | index; }", field.getIndexingScript().toString());
    assertTrue(!field.isHeader());
    // Eight field
    field = search.getConcreteField("categoriesagain");
    assertEquals("{ input categoriesagain_src | lowercase | normalize | index; }", field.getIndexingScript().toString());
    assertTrue(field.isHeader());
    // Ninth field
    field = search.getConcreteField("exactemento");
    assertEquals("{ input exactemento_src | lowercase | index | summary; }", field.getIndexingScript().toString());
    // Tenth field
    field = search.getConcreteField("category_arr");
    assertEquals(1, field.getAttributes().size());
    attribute = field.getAttributes().get("category_arr");
    assertNotNull(attribute);
    assertEquals("category_arr", attribute.getName());
    assertEquals(Attribute.Type.STRING, attribute.getType());
    assertEquals(Attribute.CollectionType.ARRAY, attribute.getCollectionType());
    assertTrue(field.isHeader());
    // Eleventh field
    field = search.getConcreteField("measurement_arr");
    assertEquals(1, field.getAttributes().size());
    attribute = field.getAttributes().get("measurement_arr");
    assertEquals("measurement_arr", attribute.getName());
    assertEquals(Attribute.Type.INTEGER, attribute.getType());
    assertEquals(Attribute.CollectionType.ARRAY, attribute.getCollectionType());
    // Rank Profiles
    RankProfile profile = rankProfileRegistry.getRankProfile(search, "default");
    assertNotNull(profile);
    assertNull(profile.getInheritedName());
    assertEquals(null, profile.getDeclaredRankSetting("measurement", RankProfile.RankSetting.Type.RANKTYPE));
    assertEquals(RankType.EMPTY, profile.getRankSetting("measurement", RankProfile.RankSetting.Type.RANKTYPE).getValue());
    profile = rankProfileRegistry.getRankProfile(search, "experimental");
    assertNotNull(profile);
    assertEquals("default", profile.getInheritedName());
    assertEquals(RankType.IDENTITY, profile.getDeclaredRankSetting("measurement", RankProfile.RankSetting.Type.RANKTYPE).getValue());
    profile = rankProfileRegistry.getRankProfile(search, "other");
    assertNotNull(profile);
    assertEquals("experimental", profile.getInheritedName());
    // The extra-document field
    SDField exact = search.getConcreteField("exact");
    assertNotNull("Extra field was parsed", exact);
    assertEquals("exact", exact.getName());
    assertEquals(Stemming.NONE, exact.getStemming());
    assertTrue(!exact.getNormalizing().doRemoveAccents());
    assertEquals("{ input title . \" \" . input category | summary | index; }", exact.getIndexingScript().toString());
    assertEquals(RankType.IDENTITY, exact.getRankType());
}
Also used : BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) MakeAliases(com.yahoo.searchdefinition.processing.MakeAliases) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) Test(org.junit.Test)

Aggregations

QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)20 Test (org.junit.Test)17 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)11 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)10 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)8 Search (com.yahoo.searchdefinition.Search)8 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)6 SDField (com.yahoo.searchdefinition.document.SDField)5 QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)4 QueryProfile (com.yahoo.search.query.profile.QueryProfile)3 QueryProfileConfigurer (com.yahoo.search.query.profile.config.QueryProfileConfigurer)1 RankProfile (com.yahoo.searchdefinition.RankProfile)1 SearchOrderer (com.yahoo.searchdefinition.derived.SearchOrderer)1 MakeAliases (com.yahoo.searchdefinition.processing.MakeAliases)1 SummarymapConfig (com.yahoo.vespa.config.search.SummarymapConfig)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1