Pagination with Elastic Search in Titan

北慕城南 提交于 2019-12-23 02:04:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!