您好我是新的ElasticSearch,我正在使用spring数据。我有2个API,使用弹性搜索在文章和话语模型中保存数据,现在当客户端应用程序为文章和话语搜索进行API调用时,它首先提供所有文章,然后提供话语数据。但我想随机化回复我该怎么做?
我的文章模型类如下
@AllArgsConstructor
@Data
@Document(indexName="articles", createIndex=true)
public class Article implements ITResult {
private String id;
private String hostContentId;
private String title;
private List<String> categories;
private String searchResultId;
@Override
public String getSummary() {
return excerpt;
}
@Override
public ContentType getContentType() {
return ContentType.ARTICLE;
}
@Override
public String getHostContentId() {
return hostContentId;
}
@Override
public String getUrl() {
return link;
}
@Override
public String getSearchResultId() {
return searchResultId;
}
public void setSearchResultId(String searchResultId) {
this.searchResultId = searchResultId;
}
}
我做了以下
SearchQuery query = new NativeSearchQueryBuilder().withIndices("articles","course")
.withPageable(new PageRequest(offset,limit))
.withFilter(multiMatchQuery(string, new String[] { "title", "excerpt", "author_name", "link"}))
.build();