[英]Using Elasticsearch Java API to match any of several words, case insensitive
我是第一次使用Elasticsearch,我敢肯定這一定很容易,但是到目前為止,使用Java API的解決方案都無法實現:
我有一系列搜索字詞,並且希望以不區分大小寫的方式返回匹配這些字詞的匹配。
這段代碼可以區分大小寫,但可以,但是我希望它不區分大小寫:
String[] terms = {"orange", "peach"};
SearchResponse response = client.prepareSearch("orders")
.setTypes("fruit")
.setQuery(
QueryBuilders.termsQuery("description", terms).minimumMatch(1)
)
.setFrom(0).setSize(10)
.setExplain(true)
.execute()
.actionGet();
for ( SearchHit hit : response.getHits()) {
String source = hit.sourceAsString();
//only case sensitive matches found...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.