Search in sources :

Example 36 with SDField

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

the class ValidateFieldTypesTest method createSingleImportedField.

private static ImportedFields createSingleImportedField(String fieldName, DataType dataType) {
    Search targetSearch = new Search("target_doc", MockApplicationPackage.createEmpty());
    SDField targetField = new SDField("target_field", dataType);
    DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSearch);
    ImportedField importedField = new ImportedField(fieldName, documentReference, targetField);
    return new ImportedFields(Collections.singletonMap(fieldName, importedField));
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) SDField(com.yahoo.searchdefinition.document.SDField) Field(com.yahoo.document.Field) ImportedField(com.yahoo.searchdefinition.document.ImportedField) SDField(com.yahoo.searchdefinition.document.SDField) Search(com.yahoo.searchdefinition.Search) ImportedField(com.yahoo.searchdefinition.document.ImportedField) ImportedFields(com.yahoo.searchdefinition.document.ImportedFields) DocumentReference(com.yahoo.searchdefinition.DocumentReference)

Example 37 with SDField

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

the class LiteralBoostTestCase method testLiteralBoost.

/**
 * Tests adding of literal boost constructs
 */
@Test
public void testLiteralBoost() {
    Search search = new Search("literalboost", null);
    RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
    SDDocumentType document = new SDDocumentType("literalboost");
    search.addDocument(document);
    SDField field1 = document.addField("a", DataType.STRING);
    field1.parseIndexingScript("{ index }");
    field1.setLiteralBoost(20);
    RankProfile other = new RankProfile("other", search, rankProfileRegistry);
    rankProfileRegistry.addRankProfile(other);
    other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333));
    Processing.process(search, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles(), true);
    DerivedConfiguration derived = new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
    // Check attribute fields
    // TODO: assert content
    derived.getAttributeFields();
    // Check il script addition
    assertIndexing(Arrays.asList("clear_state | guard { input a | tokenize normalize stem:\"SHORTEST\" | index a; }", "clear_state | guard { input a | tokenize | index a_literal; }"), search);
    // Check index info addition
    IndexInfo indexInfo = derived.getIndexInfo();
    assertTrue(indexInfo.hasCommand("a", "literal-boost"));
}
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) RankProfile(com.yahoo.searchdefinition.RankProfile) Test(org.junit.Test)

Example 38 with SDField

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

the class SearchOrdererTestCase method createDocumentReference.

private static void createDocumentReference(Search from, Search to, String refFieldName) {
    SDField refField = new TemporarySDField(refFieldName, ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create(to.getName())));
    SDDocumentType fromDocument = from.getDocument();
    fromDocument.addField(refField);
    Map<String, DocumentReference> originalMap = fromDocument.getDocumentReferences().get().referenceMap();
    HashMap<String, DocumentReference> modifiedMap = new HashMap<>(originalMap);
    modifiedMap.put(refFieldName, new DocumentReference(refField, to));
    fromDocument.setDocumentReferences(new DocumentReferences(modifiedMap));
}
Also used : TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) HashMap(java.util.HashMap) TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) DocumentReference(com.yahoo.searchdefinition.DocumentReference) DocumentReferences(com.yahoo.searchdefinition.DocumentReferences)

Example 39 with SDField

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

the class IndexSettingsTestCase method testStemmingSettings.

@Test
public void testStemmingSettings() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/indexsettings.sd");
    SDField usingDefault = (SDField) search.getDocument().getField("usingdefault");
    assertEquals(Stemming.SHORTEST, usingDefault.getStemming(search));
    SDField notStemmed = (SDField) search.getDocument().getField("notstemmed");
    assertEquals(Stemming.NONE, notStemmed.getStemming(search));
    SDField allStemmed = (SDField) search.getDocument().getField("allstemmed");
    assertEquals(Stemming.SHORTEST, allStemmed.getStemming(search));
    SDField multiStemmed = (SDField) search.getDocument().getField("multiplestems");
    assertEquals(Stemming.MULTIPLE, multiStemmed.getStemming(search));
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) Test(org.junit.Test)

Example 40 with SDField

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

the class IntegerIndex2AttributeTestCase method testIntegerIndex2Attribute.

@Test
public void testIntegerIndex2Attribute() throws IOException, ParseException {
    Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/integerindex2attribute.sd");
    search.process();
    new IntegerIndex2Attribute(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
    SDField f;
    f = search.getConcreteField("s1");
    assertTrue(f.getAttributes().isEmpty());
    assertTrue(f.existsIndex("s1"));
    f = search.getConcreteField("s2");
    assertEquals(f.getAttributes().size(), 1);
    assertTrue(f.existsIndex("s2"));
    f = search.getConcreteField("as1");
    assertTrue(f.getAttributes().isEmpty());
    assertTrue(f.existsIndex("as1"));
    f = search.getConcreteField("as2");
    assertEquals(f.getAttributes().size(), 1);
    assertTrue(f.existsIndex("as2"));
    f = search.getConcreteField("i1");
    assertEquals(f.getAttributes().size(), 1);
    assertTrue(!f.existsIndex("i1"));
    f = search.getConcreteField("i2");
    assertEquals(f.getAttributes().size(), 1);
    assertTrue(!f.existsIndex("i2"));
    f = search.getConcreteField("ai1");
    assertEquals(search.getConcreteField("ai1").getAttributes().size(), 1);
    assertTrue(!search.getConcreteField("ai1").existsIndex("ai1"));
    f = search.getConcreteField("ai2");
    assertEquals(f.getAttributes().size(), 1);
    assertTrue(!f.existsIndex("ai2"));
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDField(com.yahoo.searchdefinition.document.SDField) 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

SDField (com.yahoo.searchdefinition.document.SDField)85 Test (org.junit.Test)33 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)22 Search (com.yahoo.searchdefinition.Search)15 Attribute (com.yahoo.searchdefinition.document.Attribute)11 Index (com.yahoo.searchdefinition.Index)7 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)7 ArrayList (java.util.ArrayList)7 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)6 Field (com.yahoo.document.Field)6 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)6 ScriptExpression (com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)6 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)5 ImmutableSDField (com.yahoo.searchdefinition.document.ImmutableSDField)5 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)5 ArrayDataType (com.yahoo.document.ArrayDataType)4 DataType (com.yahoo.document.DataType)4 DocumentReference (com.yahoo.searchdefinition.DocumentReference)4 RankProfile (com.yahoo.searchdefinition.RankProfile)4 TemporarySDField (com.yahoo.searchdefinition.document.TemporarySDField)4