本文介绍了在泰坦的弹性搜索分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用与Titan的弹性搜索。我如何用泰坦做ES分页?



我看到,所以尝试这样:

 可迭代<结果<顶点>> vertices = g.indexQuery(search,v.testTitle:(mytext))
.addParameter(new Parameter(from,0))
.addParameter(new Parameter ,2))。vertices(); (结果<顶点>结果:顶点)

{
顶点tv = result.getElement();
System.out.println(tv.getProperty(testTitle)+:+ result.getScore());
}

事情是它返回所有4-5个记录,不大于2

解决方案

不支持参数。该方法仅存在于将来的实现中。
但是,您目前可以限制您的结果。以下代码应该可以工作:

  Iterable< Result< Vertex>> vertices = g.indexQuery(search,v.testTitle:(mytext))
.limit(2).vertices(); (结果<顶点>结果:顶点)

{
顶点tv = result.getElement();
System.out.println(tv.getProperty(testTitle)+:+ result.getScore());
}

...但您不能指定偏移量。



干杯,
丹尼尔


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

解决方案

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

这篇关于在泰坦的弹性搜索分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 04:02