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();
}
}
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());
}
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:<rem"o"ved&stuff>\"/>\n" + "</result>\n", result);
}
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());
}
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]"));
}
Aggregations