我在JAVA 中对 autosuggest使用弹性搜索,需要在索引中存储术语及其出现。虽然索引产品,可以多次索引特定字符串。为了避免这种情况,如果它已经存储,我们必须更新出现索引项。弹性搜索POJO:@Document(indexName = "autosuggest", type = "autosuggest")public class Autosuggest {@Id@Field(pattern ="id")private String id;@Field(pattern ="completion")private Completion completion;@Field(pattern ="occurence")private Integer occurence;public String getId() { return id;}public Completion getCompletion() { return completion;}public void setCompletion(Completion completion) { this.completion = completion;}public Integer getOccurence() { return occurence;}public void setOccurence(Integer occurence) { this.occurence = occurence;}}完成对象public class Completion {private List<String> input;private Integer weight;public List<String> getInput() { return input;}public void setInput(List<String> input) { this.input = input;}public Integer getWeight() { return weight;}public void setWeight(Integer weight) { this.weight = weight;}public Completion(List<String> input, Integer weight) { super(); this.input = input; this.weight = weight;}}弹性搜索中的示例对象 { "_index" : "autosuggest", "_type" : "autosuggest", "_id" : "BUj0zGUBr5AQqSH41l0m", "_score" : 1.0, "_source" : { "completion" : { "input" : [ "Casual Shirts for Men" ], "weight" : 2 }, "occurence" : 1 } }如果该术语已在弹性搜索中编入索引,我该如何更新出现?
添加回答
举报
0/150
提交
取消