Question

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

Était-ce utile?

La solution

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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top