Search in sources :

Example 31 with Search

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

the class VsmFieldsTestCase method reference_type_field_is_unsearchable.

@Test
public void reference_type_field_is_unsearchable() {
    Search search = new Search("test", MockApplicationPackage.createEmpty());
    search.addDocument(new SDDocumentType("test"));
    SDField refField = new TemporarySDField("ref_field", ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create("parent_type")));
    refField.parseIndexingScript("{ summary }");
    search.getDocument().addField(refField);
    VsmFields vsmFields = new VsmFields(search);
    VsmfieldsConfig.Builder cfgBuilder = new VsmfieldsConfig.Builder();
    vsmFields.getConfig(cfgBuilder);
    VsmfieldsConfig cfg = new VsmfieldsConfig(cfgBuilder);
    assertEquals(1, cfg.fieldspec().size());
    VsmfieldsConfig.Fieldspec fieldSpec = cfg.fieldspec().get(0);
    assertEquals("ref_field", fieldSpec.name());
    assertEquals(VsmfieldsConfig.Fieldspec.Searchmethod.NONE, fieldSpec.searchmethod());
}
Also used : TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) VsmfieldsConfig(com.yahoo.vespa.config.search.vsm.VsmfieldsConfig) Test(org.junit.Test)

Example 32 with Search

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

the class AttributeIndexTestCase method testAttributeIndex.

@Test
public void testAttributeIndex() throws IOException, ParseException {
    Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/attributeindex.sd");
    assertTrue(search.getConcreteField("nosettings").getAttributes().get("nosettings") != null);
    assertTrue(search.getConcreteField("specifyname").getAttributes().get("newname") != null);
    assertTrue(search.getConcreteField("specifyname2").getAttributes().get("newname2") != null);
    assertTrue(search.getConcreteField("withstaticrankname").getAttributes().get("withstaticrankname") != null);
    assertTrue(search.getConcreteField("withstaticrankname").getAttributes().get("someothername") != null);
}
Also used : Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 33 with Search

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

the class AttributesExactMatchTestCase method testAttributesExactMatch.

@Test
public void testAttributesExactMatch() throws IOException, ParseException {
    Search search = SearchBuilder.buildFromFile("src/test/examples/attributesexactmatch.sd");
    assertEquals(search.getConcreteField("color").getMatching().getType(), Matching.Type.EXACT);
    assertEquals(search.getConcreteField("artist").getMatching().getType(), Matching.Type.WORD);
    assertEquals(search.getConcreteField("drummer").getMatching().getType(), Matching.Type.WORD);
    assertEquals(search.getConcreteField("guitarist").getMatching().getType(), Matching.Type.TEXT);
    assertEquals(search.getConcreteField("saxophonist_arr").getMatching().getType(), Matching.Type.WORD);
    assertEquals(search.getConcreteField("flutist").getMatching().getType(), Matching.Type.TEXT);
    assertFalse(search.getConcreteField("genre").getMatching().getType().equals(Matching.Type.EXACT));
    assertFalse(search.getConcreteField("title").getMatching().getType().equals(Matching.Type.EXACT));
    assertFalse(search.getConcreteField("trumpetist").getMatching().getType().equals(Matching.Type.EXACT));
    assertFalse(search.getConcreteField("genre").getMatching().getType().equals(Matching.Type.WORD));
    assertFalse(search.getConcreteField("title").getMatching().getType().equals(Matching.Type.WORD));
    assertFalse(search.getConcreteField("trumpetist").getMatching().getType().equals(Matching.Type.WORD));
}
Also used : Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 34 with Search

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

the class PositionTestCase method requireThatSummaryAloneDoesNotCreateZCurve.

@Test
public void requireThatSummaryAloneDoesNotCreateZCurve() throws Exception {
    Search search = SearchBuilder.buildFromFile("src/test/examples/position_summary.sd");
    assertNull(search.getAttribute("pos"));
    assertNull(search.getAttribute("pos.x"));
    assertNull(search.getAttribute("pos.y"));
    assertNull(search.getAttribute("pos.zcurve"));
    SummaryField summary = search.getSummaryField("pos");
    assertNotNull(summary);
    assertEquals(2, summary.getSourceCount());
    Iterator<SummaryField.Source> it = summary.getSources().iterator();
    assertEquals("pos.x", it.next().getName());
    assertEquals("pos.y", it.next().getName());
    assertEquals(SummaryTransform.NONE, summary.getTransform());
    assertNull(search.getSummaryField("pos_ext.distance"));
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) Search(com.yahoo.searchdefinition.Search) Test(org.junit.Test)

Example 35 with Search

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

the class PositionTestCase method requireThatPositionCanBeAttribute.

@Test
public void requireThatPositionCanBeAttribute() throws Exception {
    Search search = SearchBuilder.buildFromFile("src/test/examples/position_attribute.sd");
    assertNull(search.getAttribute("pos"));
    assertNull(search.getAttribute("pos.x"));
    assertNull(search.getAttribute("pos.y"));
    assertPositionAttribute(search, "pos", Attribute.CollectionType.SINGLE);
    assertPositionSummary(search, "pos", false);
}
Also used : 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