Search in sources :

Example 71 with IndexFacts

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

the class LegacyCombinatorTestCase method testRankCombinator.

public void testRankCombinator() {
    Query q = new Query("?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", q.getModel().getQueryTree().toString());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts)

Example 72 with IndexFacts

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

the class LegacyCombinatorTestCase method testReqAndNot.

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

Example 73 with IndexFacts

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

the class LegacyCombinatorTestCase method testMultiPart.

public void testMultiPart() {
    Query q = new Query("?query=a&query.juhu=b&query.nalle=c");
    Execution e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    Set<String> items = new HashSet<>();
    items.add("a");
    items.add("b");
    items.add("c");
    e.search(q);
    // OK, the problem here is we have no way of knowing whether nalle or
    // juhu was added first, since we have passed through HashMap instances
    // inside the implementation
    AndItem root = (AndItem) q.getModel().getQueryTree().getRoot();
    Iterator<?> iterator = root.getItemIterator();
    while (iterator.hasNext()) {
        WordItem word = (WordItem) iterator.next();
        if (items.contains(word.stringValue())) {
            items.remove(word.stringValue());
        } else {
            assertFalse("Got unexpected item in query tree: " + word.stringValue(), true);
        }
    }
    assertEquals("Not all expected items found in query.", 0, items.size());
    Set<StringPair> nastierItems = new HashSet<>();
    nastierItems.add(new StringPair("", "a"));
    nastierItems.add(new StringPair("juhu.22[gnuff]", "b"));
    nastierItems.add(new StringPair("gnuff[8].name(\"tralala\")", "c"));
    q = new Query("?query=a&query.juhu=b&defidx.juhu=juhu.22[gnuff]&query.nalle=c&defidx.nalle=gnuff[8].name(%22tralala%22)");
    e = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts()));
    e.search(q);
    root = (AndItem) q.getModel().getQueryTree().getRoot();
    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