Search in sources :

Example 1 with VisitorParameters

use of com.yahoo.documentapi.VisitorParameters in project vespa by vespa-engine.

the class OperationHandlerImpl method visit.

@Override
public VisitResult visit(RestUri restUri, String documentSelection, VisitOptions options) throws RestApiException {
    VisitorParameters visitorParameters = createVisitorParameters(restUri, documentSelection, options);
    VisitorControlHandler visitorControlHandler = new VisitorControlHandler();
    visitorParameters.setControlHandler(visitorControlHandler);
    LocalDataVisitorHandler localDataVisitorHandler = new LocalDataVisitorHandler();
    visitorParameters.setLocalDataHandler(localDataVisitorHandler);
    final VisitorSession visitorSession;
    try {
        visitorSession = documentAccess.createVisitorSession(visitorParameters);
        // Not sure if this line is required
        visitorControlHandler.setSession(visitorSession);
    } catch (Exception e) {
        throw new RestApiException(Response.createErrorResponse(500, "Failed during parsing of arguments for visiting: " + ExceptionUtils.getStackTrace(e), restUri, RestUri.apiErrorCodes.VISITOR_ERROR));
    }
    try {
        return doVisit(visitorControlHandler, localDataVisitorHandler, restUri);
    } finally {
        visitorSession.destroy();
    }
}
Also used : VisitorSession(com.yahoo.documentapi.VisitorSession) VisitorParameters(com.yahoo.documentapi.VisitorParameters) VisitorControlHandler(com.yahoo.documentapi.VisitorControlHandler) DocumentAccessException(com.yahoo.documentapi.DocumentAccessException)

Example 2 with VisitorParameters

use of com.yahoo.documentapi.VisitorParameters in project vespa by vespa-engine.

the class VisitorSearcherTestCase method testQueryParametersDefaults.

@Test
public void testQueryParametersDefaults() throws Exception {
    VisitSearcher searcher = create();
    VisitorParameters params = searcher.getVisitorParameters(newQuery("visit?visit.selection=id.user=1234&hits=100"), null);
    assertEquals("id.user=1234", params.getDocumentSelection());
    assertEquals(1, params.getMaxBucketsPerVisitor());
    assertEquals(1, ((StaticThrottlePolicy) params.getThrottlePolicy()).getMaxPendingCount());
    assertEquals(1, params.getMaxFirstPassHits());
    assertEquals(1, params.getMaxTotalHits());
    assertEquals(32, params.getMaxPending());
    assertEquals(false, params.visitInconsistentBuckets());
}
Also used : VisitorParameters(com.yahoo.documentapi.VisitorParameters) Test(org.junit.Test)

Example 3 with VisitorParameters

use of com.yahoo.documentapi.VisitorParameters in project vespa by vespa-engine.

the class VisitorSearcherTestCase method removedDocumentIdsAreXmlEscaped.

@Test
public void removedDocumentIdsAreXmlEscaped() throws Exception {
    factory = mock(DocumentSessionFactory.class);
    when(factory.createVisitorSession(any(VisitorParameters.class))).thenAnswer((p) -> {
        VisitorParameters params = (VisitorParameters) p.getArguments()[0];
        DummyVisitorSession session = new DummyVisitorSession(params, docType);
        session.clearAutoReplyMessages();
        session.addRemoveReply("userdoc:foo:1234:<rem\"o\"ved&stuff>");
        return session;
    });
    Result result = invokeVisitRemovesSearchChain();
    assertEquals(1, result.hits().size());
    assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<remove documentid=\"userdoc:foo:1234:&lt;rem&quot;o&quot;ved&amp;stuff&gt;\"/>\n" + "</result>\n", result);
}
Also used : VisitorParameters(com.yahoo.documentapi.VisitorParameters) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 4 with VisitorParameters

use of com.yahoo.documentapi.VisitorParameters in project vespa by vespa-engine.

the class VisitorSearcherTestCase method timestampQueryParametersAreParsedAsLongs.

@Test
public void timestampQueryParametersAreParsedAsLongs() throws Exception {
    VisitorParameters params = create().getVisitorParameters(newQuery("visit?visit.selection=id.user=1234&" + "visit.fromTimestamp=1419021596000000&" + "visit.toTimestamp=1419021597000000"), null);
    assertEquals(1419021596000000L, params.getFromTimestamp());
    assertEquals(1419021597000000L, params.getToTimestamp());
}
Also used : VisitorParameters(com.yahoo.documentapi.VisitorParameters) Test(org.junit.Test)

Example 5 with VisitorParameters

use of com.yahoo.documentapi.VisitorParameters in project vespa by vespa-engine.

the class OperationHandlerImplTest method visit_field_set_covers_all_fields_by_default.

@Test
public void visit_field_set_covers_all_fields_by_default() throws Exception {
    VisitorParameters params = generatedParametersFromVisitOptions(emptyVisitOptions());
    assertThat(params.fieldSet(), equalTo("document-type:[document]"));
}
Also used : VisitorParameters(com.yahoo.documentapi.VisitorParameters) Test(org.junit.Test)

Aggregations

VisitorParameters (com.yahoo.documentapi.VisitorParameters)17 Test (org.junit.Test)13 StaticThrottlePolicy (com.yahoo.messagebus.StaticThrottlePolicy)3 DocumentAccessException (com.yahoo.documentapi.DocumentAccessException)2 ParseException (com.yahoo.document.select.parser.ParseException)1 ProgressToken (com.yahoo.documentapi.ProgressToken)1 VisitorControlHandler (com.yahoo.documentapi.VisitorControlHandler)1 VisitorSession (com.yahoo.documentapi.VisitorSession)1 Result (com.yahoo.search.Result)1 Map (java.util.Map)1