use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.
the class SearchBuilder method build.
/**
* Processes and finalizes the imported search definitions so that they become available through the {@link
* #getSearch(String)} method.
*
* @throws IllegalStateException Thrown if this method has already been called.
* @param deployLogger The logger to use during build
*/
public void build(boolean validate, DeployLogger deployLogger) {
if (isBuilt)
throw new IllegalStateException("Model already built");
List<Search> built = new ArrayList<>();
List<SDDocumentType> sdocs = new ArrayList<>();
sdocs.add(SDDocumentType.VESPA_DOCUMENT);
for (Search search : searchList) {
if (search.hasDocument()) {
sdocs.add(search.getDocument());
}
}
SDDocumentTypeOrderer orderer = new SDDocumentTypeOrderer(sdocs, deployLogger);
orderer.process();
for (SDDocumentType sdoc : orderer.getOrdered()) {
new FieldOperationApplierForStructs().process(sdoc);
new FieldOperationApplier().process(sdoc);
}
DocumentReferenceResolver resolver = new DocumentReferenceResolver(searchList);
sdocs.forEach(resolver::resolveReferences);
if (validate)
new DocumentGraphValidator().validateDocumentGraph(sdocs);
DocumentModelBuilder builder = new DocumentModelBuilder(model);
for (Search search : new SearchOrderer().order(searchList)) {
new FieldOperationApplierForSearch().process(search);
// These two needed for a couple of old unit tests, ideally these are just read from app
process(search, deployLogger, new QueryProfiles(queryProfileRegistry), validate);
built.add(search);
}
builder.addToModel(searchList);
if (validate && !builder.valid())
throw new IllegalArgumentException("Impossible to build a correct model.");
searchList = built;
isBuilt = true;
}
use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.
the class SummaryMapTestCase method testPositionDeriving.
@Test
public void testPositionDeriving() throws IOException, ParseException {
Search search = new Search("store", null);
SDDocumentType document = new SDDocumentType("store");
search.addDocument(document);
String fieldName = "location";
SDField field = document.addField(fieldName, PositionDataType.INSTANCE);
field.parseIndexingScript("{ attribute | summary }");
Processing.process(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true);
SummaryMap summaryMap = new SummaryMap(search, new Summaries(search, new BaseDeployLogger()));
Iterator transforms = summaryMap.resultTransformIterator();
FieldResultTransform transform = (FieldResultTransform) transforms.next();
assertEquals(fieldName, transform.getFieldName());
assertEquals(SummaryTransform.GEOPOS, transform.getTransform());
transform = (FieldResultTransform) transforms.next();
assertEquals(PositionDataType.getPositionSummaryFieldName(fieldName), transform.getFieldName());
assertEquals(SummaryTransform.POSITIONS, transform.getTransform());
transform = (FieldResultTransform) transforms.next();
assertEquals(PositionDataType.getDistanceSummaryFieldName(fieldName), transform.getFieldName());
assertEquals(SummaryTransform.DISTANCE, transform.getTransform());
transform = (FieldResultTransform) transforms.next();
assertEquals("rankfeatures", transform.getFieldName());
assertEquals(SummaryTransform.RANKFEATURES, transform.getTransform());
transform = (FieldResultTransform) transforms.next();
assertEquals("summaryfeatures", transform.getFieldName());
assertEquals(SummaryTransform.SUMMARYFEATURES, transform.getTransform());
transform = (FieldResultTransform) transforms.next();
assertEquals("location_zcurve", transform.getFieldName());
assertEquals(SummaryTransform.ATTRIBUTE, transform.getTransform());
assertTrue(!transforms.hasNext());
SummarymapConfig.Builder scb = new SummarymapConfig.Builder();
summaryMap.getConfig(scb);
SummarymapConfig c = new SummarymapConfig(scb);
assertEquals(-1, c.defaultoutputclass());
assertEquals(c.override().size(), 6);
assertEquals(c.override(0).field(), fieldName);
assertEquals(c.override(0).command(), "geopos");
assertEquals(c.override(0).arguments(), PositionDataType.getZCurveFieldName(fieldName));
assertEquals(c.override(1).field(), PositionDataType.getPositionSummaryFieldName(fieldName));
assertEquals(c.override(1).command(), "positions");
assertEquals(c.override(1).arguments(), PositionDataType.getZCurveFieldName(fieldName));
assertEquals(c.override(2).field(), PositionDataType.getDistanceSummaryFieldName(fieldName));
assertEquals(c.override(2).command(), "absdist");
assertEquals(c.override(2).arguments(), PositionDataType.getZCurveFieldName(fieldName));
assertEquals(c.override(3).field(), "rankfeatures");
assertEquals(c.override(3).command(), "rankfeatures");
assertEquals(c.override(3).arguments(), "");
assertEquals(c.override(4).field(), "summaryfeatures");
assertEquals(c.override(4).command(), "summaryfeatures");
assertEquals(c.override(4).arguments(), "");
assertEquals(c.override(5).field(), "location_zcurve");
assertEquals(c.override(5).command(), "attribute");
assertEquals(c.override(5).arguments(), "location_zcurve");
}
use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.
the class BoldingTestCase method testBoldingNonString.
@Test
public void testBoldingNonString() throws IOException, ParseException {
try {
Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/processing/boldnonstring.sd");
new Bolding(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
fail();
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("'bolding: on' for non-text field"));
}
}
use of com.yahoo.vespa.model.container.search.QueryProfiles in project vespa by vespa-engine.
the class IdTestCase method testExplicitUpperCaseIdField.
@Test
@SuppressWarnings({ "deprecation" })
public void testExplicitUpperCaseIdField() {
Search search = new Search("test", null);
SDDocumentType document = new SDDocumentType("test");
search.addDocument(document);
SDField uri = new SDField("URI", DataType.URI);
uri.parseIndexingScript("{ summary | index }");
document.addField(uri);
Processing.process(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true);
assertNull(document.getField("uri"));
assertNull(document.getField("Uri"));
assertNotNull(document.getField("URI"));
}
use of com.yahoo.vespa.model.container.search.QueryProfiles 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"));
}
Aggregations