Search in sources :

Example 6 with IndexFacts

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());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 7 with IndexFacts

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());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 8 with IndexFacts

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());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 9 with IndexFacts

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"));
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) Query(com.yahoo.search.Query) Test(org.junit.Test)

Example 10 with IndexFacts

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());
}
Also used : IndexFacts(com.yahoo.prelude.IndexFacts) Query(com.yahoo.search.Query) Index(com.yahoo.prelude.Index)

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