Search in sources :

Example 66 with Result

use of com.yahoo.search.Result in project vespa by vespa-engine.

the class ValidatePredicateSearcherTestCase method testQueryOutOfBounds.

@Test
public void testQueryOutOfBounds() {
    ValidatePredicateSearcher searcher = new ValidatePredicateSearcher();
    String q = "select * from sources * where predicate(predicate_field,0,{\"age\":200L});";
    Result r = doSearch(searcher, q, "predicate-bounds [0..99]");
    assertEquals(ErrorMessage.createIllegalQuery("age=200 outside configured predicate bounds."), r.hits().getError());
}
Also used : ValidatePredicateSearcher(com.yahoo.prelude.searcher.ValidatePredicateSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 67 with Result

use of com.yahoo.search.Result in project vespa by vespa-engine.

the class ValidatePredicateSearcherTestCase method testValidQuery.

@Test
public void testValidQuery() {
    ValidatePredicateSearcher searcher = new ValidatePredicateSearcher();
    String q = "select * from sources * where predicate(predicate_field,0,{\"age\":20L});";
    Result r = doSearch(searcher, q, "predicate-bounds [0..99]");
    assertNull(r.hits().getError());
}
Also used : ValidatePredicateSearcher(com.yahoo.prelude.searcher.ValidatePredicateSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 68 with Result

use of com.yahoo.search.Result in project vespa by vespa-engine.

the class RecallSearcherTestCase method assertQueryTree.

private static void assertQueryTree(String query, List<String> ranked, List<String> unranked) {
    RecallSearcher searcher = new RecallSearcher();
    Query obj = new Query(query);
    Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(obj);
    if (result.hits().getError() != null) {
        fail(result.hits().getError().toString());
    }
    List<String> myRanked = new ArrayList<>(ranked);
    List<String> myUnranked = new ArrayList<>(unranked);
    Stack<Item> stack = new Stack<>();
    stack.push(obj.getModel().getQueryTree().getRoot());
    while (!stack.isEmpty()) {
        Item item = stack.pop();
        if (item instanceof WordItem) {
            String word = ((WordItem) item).getWord();
            if (item.isRanked()) {
                int idx = myRanked.indexOf(word);
                if (idx < 0) {
                    fail("Term '" + word + "' not expected as ranked term.");
                }
                myRanked.remove(idx);
            } else {
                int idx = myUnranked.indexOf(word);
                if (idx < 0) {
                    fail("Term '" + word + "' not expected as unranked term.");
                }
                myUnranked.remove(idx);
            }
        }
        if (item instanceof CompositeItem) {
            CompositeItem lst = (CompositeItem) item;
            for (Iterator<?> it = lst.getItemIterator(); it.hasNext(); ) {
                stack.push((Item) it.next());
            }
        }
    }
    if (!myRanked.isEmpty()) {
        fail("Ranked terms " + myRanked + " not found.");
    }
    if (!myUnranked.isEmpty()) {
        fail("Unranked terms " + myUnranked + " not found.");
    }
}
Also used : CompositeItem(com.yahoo.prelude.query.CompositeItem) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) RecallSearcher(com.yahoo.prelude.querytransform.RecallSearcher) ArrayList(java.util.ArrayList) Result(com.yahoo.search.Result) Stack(java.util.Stack) CompositeItem(com.yahoo.prelude.query.CompositeItem) NullItem(com.yahoo.prelude.query.NullItem) Item(com.yahoo.prelude.query.Item) WordItem(com.yahoo.prelude.query.WordItem) Execution(com.yahoo.search.searchchain.Execution) WordItem(com.yahoo.prelude.query.WordItem)

Example 69 with Result

use of com.yahoo.search.Result in project vespa by vespa-engine.

the class RecallSearcherTestCase method testDenyRankItems.

@Test
public void testDenyRankItems() {
    RecallSearcher searcher = new RecallSearcher();
    Query query = new Query("?recall=foo");
    Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(query);
    assertNotNull(result.hits().getError());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) RecallSearcher(com.yahoo.prelude.querytransform.RecallSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 70 with Result

use of com.yahoo.search.Result in project vespa by vespa-engine.

the class RecallSearcherTestCase method testIgnoreEmptyProperty.

@Test
public void testIgnoreEmptyProperty() {
    RecallSearcher searcher = new RecallSearcher();
    Query query = new Query();
    Result result = new Execution(searcher, Execution.Context.createContextStub()).search(query);
    assertNull(result.hits().getError());
    assertTrue(query.getModel().getQueryTree().getRoot() instanceof NullItem);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) RecallSearcher(com.yahoo.prelude.querytransform.RecallSearcher) NullItem(com.yahoo.prelude.query.NullItem) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

Result (com.yahoo.search.Result)398 Test (org.junit.Test)231 Query (com.yahoo.search.Query)229 Execution (com.yahoo.search.searchchain.Execution)127 Searcher (com.yahoo.search.Searcher)94 Hit (com.yahoo.search.result.Hit)72 Chain (com.yahoo.component.chain.Chain)48 FastHit (com.yahoo.prelude.fastsearch.FastHit)36 HitGroup (com.yahoo.search.result.HitGroup)29 JSONString (com.yahoo.prelude.hitfield.JSONString)26 HashMap (java.util.HashMap)21 FeedContext (com.yahoo.feedapi.FeedContext)19 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)19 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)19 ClusterList (com.yahoo.vespaclient.ClusterList)19 ErrorMessage (com.yahoo.search.result.ErrorMessage)17 Choice (com.yahoo.search.pagetemplates.model.Choice)16 Organizer (com.yahoo.search.pagetemplates.engine.Organizer)15 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)15 DeterministicResolver (com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver)14