use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class DefaultPositionSearcher method search.
@Override
public com.yahoo.search.Result search(Query query, Execution execution) {
Location location = query.getRanking().getLocation();
if (location != null && (location.getAttribute() == null)) {
IndexFacts facts = execution.context().getIndexFacts();
List<String> search = facts.newSession(query.getModel().getSources(), query.getModel().getRestrict()).documentTypes();
for (String sd : search) {
String defaultPosition = facts.getDefaultPosition(sd);
if (defaultPosition != null) {
location.setAttribute(defaultPosition);
}
}
if (location.getAttribute() == null) {
location.setAttribute(facts.getDefaultPosition(null));
}
}
return execution.search(query);
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class DuplicateSourceTestCase method testDuplicateSource.
@Test
public void testDuplicateSource() {
// Set up a single cluster and chain (chain1), containing a MockBackendSearcher and having 2 doc types (doc1, doc2)
MockBackendSearcher mockBackendSearcher = new MockBackendSearcher();
SearchChainRegistry searchChains = new SearchChainRegistry();
searchChains.register(new Chain<>("chain1", mockBackendSearcher));
IndexFacts indexFacts = new IndexFacts();
Map<String, List<String>> clusters = new HashMap<>();
clusters.put("chain1", ImmutableList.of("doc1", "doc2"));
indexFacts.setClusters(clusters);
SearchChainResolver resolver = new SearchChainResolver.Builder().addSearchChain(new ComponentId("chain1"), ImmutableList.of("doc1", "doc2")).build();
FederationSearcher searcher = new FederationSearcher(new ComponentId("test"), resolver);
Result result = searcher.search(new Query("?query=test&sources=doc1%2cdoc2"), new Execution(Execution.Context.createContextStub(searchChains, indexFacts)));
assertNull(result.hits().getError());
assertEquals(1, mockBackendSearcher.getInvocationCount());
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class ValidatePredicateSearcherTestCase method doSearch.
private static Result doSearch(ValidatePredicateSearcher searcher, String yqlQuery, String command) {
QueryTree queryTree = new YqlParser(new ParserEnvironment()).parse(new Parsable().setQuery(yqlQuery));
Query query = new Query();
query.getModel().getQueryTree().setRoot(queryTree.getRoot());
TreeMap<String, List<String>> masterClusters = new TreeMap<>();
masterClusters.put("cluster", Arrays.asList("document"));
SearchDefinition searchDefinition = new SearchDefinition("document");
Index index = new Index("predicate_field");
index.addCommand(command);
searchDefinition.addIndex(index);
Map<String, SearchDefinition> searchDefinitionMap = new HashMap<>();
searchDefinitionMap.put("document", searchDefinition);
IndexFacts indexFacts = new IndexFacts(new IndexModel(masterClusters, searchDefinitionMap, searchDefinition));
Execution.Context context = new Execution.Context(null, indexFacts, null, new RendererRegistry(MoreExecutors.directExecutor()), new SimpleLinguistics());
return new Execution(searcher, context).search(query);
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class SourceRefResolverTestCase method setupIndexFacts.
private static void setupIndexFacts() {
TreeMap<String, List<String>> masterClusters = new TreeMap<>();
masterClusters.put(cluster1, Arrays.asList("document1", "document2"));
masterClusters.put(cluster2, Arrays.asList("document1"));
masterClusters.put(cluster3, Arrays.asList("document3"));
indexFacts = new IndexFacts(new IndexModel(masterClusters, null, null));
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class LiteralBoostSearcherTestCase method createIndexFacts.
private IndexFacts createIndexFacts() {
Map<String, List<String>> clusters = new LinkedHashMap<>();
clusters.put("cluster1", Arrays.asList("type1", "type2", "type3"));
clusters.put("cluster2", Arrays.asList("type4", "type5"));
Map<String, SearchDefinition> searchDefs = new LinkedHashMap<>();
searchDefs.put("type1", createSearchDefinitionWithFields("type1", true));
searchDefs.put("type2", createSearchDefinitionWithFields("type2", false));
searchDefs.put("type3", new SearchDefinition("type3"));
searchDefs.put("type3", new SearchDefinition("type3"));
searchDefs.put("type4", new SearchDefinition("type4"));
searchDefs.put("type5", new SearchDefinition("type5"));
SearchDefinition union = new SearchDefinition("union");
return new IndexFacts(new IndexModel(clusters, searchDefs, union));
}
Aggregations