Search in sources :

Example 16 with ErrorMessage

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

the class FeedResponse method addError.

public FeedResponse addError(com.yahoo.container.protect.Error code, String error) {
    errorMessages.add(new ErrorMessage(code.code, error));
    errors.add(error);
    return this;
}
Also used : ErrorMessage(com.yahoo.search.result.ErrorMessage)

Example 17 with ErrorMessage

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

the class FastSearcherTestCase method testNullQuery.

@Test
public void testNullQuery() {
    Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL);
    FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbInfoConfig);
    String query = "?junkparam=ignored";
    Result result = doSearch(fastSearcher, new Query(query), 0, 10);
    ErrorMessage message = result.hits().getError();
    assertNotNull("Got error", message);
    assertEquals("Null query", message.getMessage());
    assertEquals(query, message.getDetailedMessage());
    assertEquals(Error.NULL_QUERY.code, message.getCode());
}
Also used : Query(com.yahoo.search.Query) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 18 with ErrorMessage

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

the class FastSearcherTestCase method testDispatchDotSummaries.

@Test
public void testDispatchDotSummaries() {
    Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL);
    DocumentdbInfoConfig documentdbConfigWithOneDb = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("testDb").summaryclass(new DocumentdbInfoConfig.Documentdb.Summaryclass.Builder().name("simple").id(7)).rankprofile(new DocumentdbInfoConfig.Documentdb.Rankprofile.Builder().name("simpler").hasRankFeatures(false).hasSummaryFeatures(false))));
    FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbConfigWithOneDb);
    String query = "?query=sddocname:a&dispatch.summaries";
    Result result = doSearch(fastSearcher, new Query(query), 0, 10);
    ErrorMessage message = result.hits().getError();
    assertNotNull("Got error", message);
    assertEquals("Invalid query parameter", message.getMessage());
    assertEquals("When using dispatch.summaries and your summary/rankprofile require the query,  you need to enable ranking.queryCache.", message.getDetailedMessage());
    assertEquals(Error.INVALID_QUERY_PARAMETER.code, message.getCode());
    query = "?query=sddocname:a&dispatch.summaries&ranking.queryCache";
    result = doSearch(fastSearcher, new Query(query), 0, 10);
    assertNull(result.hits().getError());
    query = "?query=sddocname:a&dispatch.summaries&summary=simple&ranking=simpler";
    result = doSearch(fastSearcher, new Query(query), 0, 10);
    assertNull(result.hits().getError());
}
Also used : Query(com.yahoo.search.Query) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Result(com.yahoo.search.Result) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) ErrorMessage(com.yahoo.search.result.ErrorMessage) Test(org.junit.Test)

Example 19 with ErrorMessage

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

the class MinimalQueryInserterTestCase method testMaxOffset.

@Test
public void testMaxOffset() {
    Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040031offset%2040000%3B");
    Result r = execution.search(query);
    assertEquals(1, r.hits().getErrorHit().errors().size());
    ErrorMessage e = r.hits().getErrorHit().errorIterator().next();
    assertEquals(com.yahoo.container.protect.Error.INVALID_QUERY_PARAMETER.code, e.getCode());
    assertTrue(e.getDetailedMessage().indexOf("max offset") >= 0);
}
Also used : Query(com.yahoo.search.Query) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 20 with ErrorMessage

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

the class MinimalQueryInserterTestCase method testMaxLimit.

@Test
public void testMaxLimit() {
    Query query = new Query("search/?yql=select%20*%20from%20sources%20*%20where%20title%20contains%20%22madonna%22%20limit%2040000offset%207%3B");
    Result r = execution.search(query);
    assertEquals(1, r.hits().getErrorHit().errors().size());
    ErrorMessage e = r.hits().getErrorHit().errorIterator().next();
    assertEquals(com.yahoo.container.protect.Error.INVALID_QUERY_PARAMETER.code, e.getCode());
    assertTrue(e.getDetailedMessage().indexOf("max hits") >= 0);
}
Also used : Query(com.yahoo.search.Query) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

ErrorMessage (com.yahoo.search.result.ErrorMessage)23 Result (com.yahoo.search.Result)16 Query (com.yahoo.search.Query)10 Test (org.junit.Test)9 ErrorHit (com.yahoo.search.result.ErrorHit)4 IndexFacts (com.yahoo.prelude.IndexFacts)3 Execution (com.yahoo.search.searchchain.Execution)3 MockBackend (com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend)2 Hit (com.yahoo.search.result.Hit)2 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Metric (com.yahoo.jdisc.Metric)1 URI (com.yahoo.net.URI)1 DocumentdbInfoConfig (com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)1 FastHit (com.yahoo.prelude.fastsearch.FastHit)1 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)1 JSONString (com.yahoo.prelude.hitfield.JSONString)1 XMLString (com.yahoo.prelude.hitfield.XMLString)1 FederationTarget (com.yahoo.search.federation.selection.FederationTarget)1