使用boolQuery
进行查询,以匹配我在弹性搜索中的词组。我的短语是Variable Air Volume Controller
,并尝试使用下面的Java代码匹配该短语。
keyword : Variable Air Volume Controller
请在下面找到我的Java代码:
QueryBuilder qb1 = QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("catalog_attr_value", keyword))
.filter(QueryBuilders.termQuery("locale", USER_LOCALE));
但是变得像下面一样。
Response :
Controller to control the electronics
Air cooler
variable controls
...
...
...
但是我希望像下面这样回应:(完全匹配)
Variable Air Volume Controller
请在下面找到我的映射文件:
PUT catalog
{
"settings": {
"analysis": {
"analyzer": {
"value_analyzer": {
"type": "custom",
"tokenizer": "whitespace",
"char_filter": [
"html_strip"
],
"filter": ["lowercase", "asciifolding"]
}
}
}
},
"mappings": {
"doc": {
"properties": {
"catalog_attr_value": {
"type": "text",
"analyzer": "value_analyzer"
},
"catalog_id": {
"type": "long"
},
"catalog_attr_name":{
"type":"keyword"
},
"locale":{
"type":"keyword"
}
}
}
}
}