如何在Elasticseach 6.2.3中使用TermVectorsResponse?

时间:2018-08-14 07:17:15

标签: java spring-boot elasticsearch

我正在使用TermVectorsRequestBuilder通过弹性搜索6.2.3和spring-boot 2.0.3获取特定关键字的结果。

以下是代码:-

 TermVectorsRequestBuilder requestBuilder;       
    requestBuilder = client.prepareTermVectors().setIndex("index1").setType("type1").setTermStatistics(true).setFieldStatistics(false);
    TermVectorsResponse response;
    try {
        response = requestBuilder.execute().actionGet();
    } catch (NoNodeAvailableException e) {
         throw e;
    }
    try {
        XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON).prettyPrint();
        builder.startObject();
        response.toXContent(builder, ToXContent.EMPTY_PARAMS);

执行代码时出现错误:-

Can not start an object, expecting field name (context: Object)

请提出如何解决该错误的建议。

0 个答案:

没有答案