Search in sources :

Example 66 with IndexFacts

use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.

the class IndexFactsTestCase method createIndexFacts.

private IndexFacts createIndexFacts() {
    ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
    IndexInfoConfig config = getter.getConfig(INDEXFACTS_TESTING);
    List<String> clusterOne = new ArrayList<>();
    List<String> clusterTwo = new ArrayList<>();
    clusterOne.addAll(Arrays.asList("one", "two"));
    clusterTwo.addAll(Arrays.asList("one", "three"));
    Map<String, List<String>> clusters = new HashMap<>();
    clusters.put("clusterOne", clusterOne);
    clusters.put("clusterTwo", clusterTwo);
    IndexFacts indexFacts = new IndexFacts(new IndexModel(config, clusters));
    return indexFacts;
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) HashMap(java.util.HashMap) ConfigGetter(com.yahoo.config.subscription.ConfigGetter) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel)

Example 67 with IndexFacts

use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.

the class LegacyCombinatorTestCase method testIncompatibleNewAndOldQuery.

public void testIncompatibleNewAndOldQuery() {
    Query q = new Query("?query.juhu=b&defidx.juhu=a&query.juhu.defidx=c");
    Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("NULL", q.getModel().getQueryTree().toString());
    assertTrue("No expected error found.", q.errors().size() > 0);
    assertEquals("Did not get invalid query parameter error as expected.", Error.INVALID_QUERY_PARAMETER.code, q.errors().get(0).getCode());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts)

Example 68 with IndexFacts

use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.

the class LegacyCombinatorTestCase method testStraightForwardSearch.

public void testStraightForwardSearch() {
    Query q = new Query("?query=a&query.juhu=b");
    Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("AND a b", q.getModel().getQueryTree().toString());
    q = new Query("?query=a&query.juhu=b&defidx.juhu=juhu.22[gnuff]");
    e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("AND a juhu.22[gnuff]:b", q.getModel().getQueryTree().toString());
    q = new Query("?query=a&query.juhu=");
    e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("a", q.getModel().getQueryTree().toString());
    q = new Query("?query=a+c&query.juhu=b");
    e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("AND a c b", q.getModel().getQueryTree().toString());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts)

Example 69 with IndexFacts

use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.

the class LegacyCombinatorTestCase method testRankAndNot.

public void testRankAndNot() {
    Query q = new Query("?query.yahoo=2&query.yahoo.defidx=1&query.yahoo.operator=not&query.juhu=b&query.juhu.defidx=nalle&query.juhu.operator=rank");
    Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    assertEquals("+nalle:b -1:2", q.getModel().getQueryTree().toString());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts)

Example 70 with IndexFacts

use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.

the class LegacyCombinatorTestCase method testNewAndOld.

public void testNewAndOld() {
    Query q = new Query("?query.juhu=b&defidx.juhu=nalle&query.bamse=z&query.bamse.defidx=y");
    Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    Set<StringPair> nastierItems = new HashSet<>();
    nastierItems.add(new StringPair("nalle", "b"));
    nastierItems.add(new StringPair("y", "z"));
    e.search(q);
    AndItem root = (AndItem) q.getModel().getQueryTree().getRoot();
    Iterator<?> iterator = root.getItemIterator();
    while (iterator.hasNext()) {
        WordItem word = (WordItem) iterator.next();
        StringPair asPair = new StringPair(word.getIndexName(), word.stringValue());
        if (nastierItems.contains(asPair)) {
            nastierItems.remove(asPair);
        } else {
            assertFalse("Got unexpected item in query tree: (" + word.getIndexName() + ", " + word.stringValue() + ")", true);
        }
    }
    assertEquals("Not all expected items found in query.", 0, nastierItems.size());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) HashSet(java.util.HashSet)

Aggregations

IndexFacts (com.yahoo.prelude.IndexFacts)73 Query (com.yahoo.search.Query)41 Execution (com.yahoo.search.searchchain.Execution)34 Test (org.junit.Test)26 Index (com.yahoo.prelude.Index)22 IndexModel (com.yahoo.prelude.IndexModel)12 Result (com.yahoo.search.Result)8 ArrayList (java.util.ArrayList)8 List (java.util.List)8 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)7 SearchDefinition (com.yahoo.prelude.SearchDefinition)6 IndexInfoConfig (com.yahoo.search.config.IndexInfoConfig)6 Chain (com.yahoo.component.chain.Chain)5 Token (com.yahoo.prelude.query.parser.Token)5 Tokenizer (com.yahoo.prelude.query.parser.Tokenizer)5 ConfigGetter (com.yahoo.config.subscription.ConfigGetter)4 AndItem (com.yahoo.prelude.query.AndItem)4 WordItem (com.yahoo.prelude.query.WordItem)4 HashSet (java.util.HashSet)4 LinkedHashMap (java.util.LinkedHashMap)4