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());
}
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);
}
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));
}
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"));
}
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);
}
Aggregations