问题
I am using Elastic Search with Titan. How can I do pagination in ES with titan?
I saw THIS and so was trying this:
Iterable<Result<Vertex>> vertices = g.indexQuery("search","v.testTitle:(mytext)")
.addParameter(new Parameter("from", 0))
.addParameter(new Parameter("size", 2)).vertices();
for (Result<Vertex> result : vertices) {
Vertex tv = result.getElement();
System.out.println(tv.getProperty("testTitle")+ ": " + result.getScore());
}
The thing is it return all 4-5 records not in the size of 2
回答1:
parameters are not yet supported. The method only exists for future implementations. However, you can currently limit your result. The following code should work:
Iterable<Result<Vertex>> vertices = g.indexQuery("search","v.testTitle:(mytext)")
.limit(2).vertices();
for (Result<Vertex> result : vertices) {
Vertex tv = result.getElement();
System.out.println(tv.getProperty("testTitle")+ ": " + result.getScore());
}
...but you can't specify an offset.
Cheers, Daniel
回答2:
I don know anyrthing about titan.But for implementing pagination concept in Elasticsearch ,you can use scroll concept.It will help a lot and Its like db cursor.. it reduces CPU usage a lot.
Refer http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-scroll.html
来源:https://stackoverflow.com/questions/22436106/pagination-with-elastic-search-in-titan