我使用下面的函数来获取一些id集合的术语向量。在
public static void builtTermVectorRequest(Client client, String index, Map<String, String> postIDs) {
TermVectorsRequest termVectorsRequest = new TermVectorsRequest();
termVectorsRequest.index(index).type("post");
for (Map.Entry<String, String> entry : postIDs.entrySet()) {
String currentPostId = entry.getKey();
String currentParentID = entry.getValue();
termVectorsRequest
.id(currentPostId)
.parent(currentParentID)
.termStatistics(true)
.selectedFields("content");
}
MultiTermVectorsRequestBuilder mtbuilder = client.prepareMultiTermVectors();
mtbuilder.add(termVectorsRequest);
MultiTermVectorsResponse response = mtbuilder.execute().actionGet();
XContentBuilder builder;
try {
builder = XContentFactory.jsonBuilder().startObject();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.endObject();
System.out.println(builder.prettyPrint().string());
} catch (IOException e) {}
}
这里我有一些文档id和它们的父id,因为这些文档是子文档。在
我知道文件即使存在也找不到。在
为了确认我在Python中使用了相同的方法:
^{2}$结果又回来了。在
Java代码有什么问题?在
我尝试了更多关于如何将
TermVectorsRequest
与MultiTermVectorsRequestBuilder
一起使用的组合,最后得出了以下可行的解决方案:相关问题 更多 >
编程相关推荐