use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class BlendingSearcherTestCase method testExistingAndNonExistingBackendCausesBothErrorAndResult.
@Test
public void testExistingAndNonExistingBackendCausesBothErrorAndResult() {
BlendingSearcherWrapper searcher = setupFirstAndSecond();
Query query = new Query("/search?query=banana&search=first,nonesuch,second");
Result result = new Execution(searcher, Execution.Context.createContextStub(new IndexFacts())).search(query);
assertEquals(3, result.getConcreteHitCount());
assertEquals(300.0, result.hits().get(1).getRelevance().getScore(), delta);
assertEquals(200.0, result.hits().get(2).getRelevance().getScore(), delta);
assertEquals(100.0, result.hits().get(3).getRelevance().getScore(), delta);
assertNotNull(result.hits().getError());
ErrorMessage e = result.hits().getError();
// TODO: Do not depend on sources order
assertEquals("Could not resolve source ref 'nonesuch'. Valid source refs are first, second.", e.getDetailedMessage());
}
use of com.yahoo.prelude.IndexFacts 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.prelude.IndexFacts 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.prelude.IndexFacts in project vespa by vespa-engine.
the class IndexFactsTestCase method testIndicesInAnyConfigurationAreIndicesInDefault.
@Test
public void testIndicesInAnyConfigurationAreIndicesInDefault() {
IndexFacts.Session indexFacts = createIndexFacts().newSession(new Query());
assertTrue(indexFacts.isIndex("a"));
assertTrue(indexFacts.isIndex("b"));
assertTrue(indexFacts.isIndex("c"));
assertTrue(indexFacts.isIndex("d"));
assertFalse(indexFacts.isIndex("anythingelse"));
}
use of com.yahoo.prelude.IndexFacts in project vespa by vespa-engine.
the class IndexFactsTestCase method assertExactIsWorking.
private void assertExactIsWorking(String indexName) {
Index index = new Index(indexName);
index.setExact(true, "^^^");
IndexFacts indexFacts = createIndexFacts();
indexFacts.addIndex("artist", index);
Query query = new Query();
query.getModel().getSources().add("artist");
assertTrue(indexFacts.newSession(query).getIndex(indexName).isExact());
Query q = newQuery("?query=" + indexName + ":foo...&search=artist", indexFacts);
assertEquals(indexName + ":foo...", q.getModel().getQueryTree().getRoot().toString());
}
Aggregations