use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class BlendingSearcherTestCase method testOnlySecondBackend.
@Test
public void testOnlySecondBackend() {
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=second");
Result result = new Execution(searcher, Execution.Context.createContextStub()).search(query);
assertEquals(2, result.getHitCount());
assertEquals(300.0, result.hits().get(0).getRelevance().getScore(), delta);
assertEquals(100.0, result.hits().get(1).getRelevance().getScore(), delta);
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class BlendingSearcherTestCase method testNonexistingBackendCausesError.
@Test
public void testNonexistingBackendCausesError() {
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=nonesuch");
Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(query);
assertEquals(0, result.getConcreteHitCount());
assertNotNull(result.hits().getError());
ErrorMessage e = result.hits().getError();
assertEquals("Invalid query parameter", e.getMessage());
// assertEquals("No source named 'nonesuch' to search. Valid sources are [first, second]",
// e.getDetailedMessage());
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class BlendingSearcherTestCase method testNonexistingBackendsCausesErrorOnFirst.
@Test
public void testNonexistingBackendsCausesErrorOnFirst() {
// Feel free to change to include all in the detail message...
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=nonesuch,orsuch");
Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(query);
assertEquals(0, result.getConcreteHitCount());
assertNotNull(result.hits().getError());
ErrorMessage e = result.hits().getError();
assertEquals("Invalid query parameter", e.getMessage());
// TODO: Do not depend on sources order
assertEquals("4: Invalid query parameter: Could not resolve source ref 'nonesuch'. Could not resolve source ref 'orsuch'. Valid source refs are first, second.", e.toString());
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class CollapsePhraseSearcherTestCase method transformQuery.
private String transformQuery(String rawQuery) {
CollapsePhraseSearcher searcher = new CollapsePhraseSearcher();
Query query = new Query(rawQuery);
new Execution(searcher, Execution.Context.createContextStub()).search(query);
Item newRoot = query.getModel().getQueryTree().getRoot();
if (newRoot != null)
return newRoot.toString();
else
return null;
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class NonPhrasingSearcherTestCase method testNoNonPhrasingIfNoOtherPhrases.
@Test
public void testNoNonPhrasingIfNoOtherPhrases() {
searcher = new NonPhrasingSearcher("src/test/java/com/yahoo/prelude/querytransform/test/test-fsa.fsa");
Query query = new Query("?query=tudor+vidor");
new Execution(searcher, Execution.Context.createContextStub()).search(query);
CompositeItem item = (CompositeItem) query.getModel().getQueryTree().getRoot();
assertEquals(2, item.getItemCount());
assertEquals("tudor", ((WordItem) item.getItem(0)).getWord());
assertEquals("vidor", ((WordItem) item.getItem(1)).getWord());
}
Aggregations