ElasticSearch 仅返回具有不同值的文档
2022-09-03 00:05:45
假设我有这个给定的数据
{
"name" : "ABC",
"favorite_cars" : [ "ferrari","toyota" ]
}, {
"name" : "ABC",
"favorite_cars" : [ "ferrari","toyota" ]
}, {
"name" : "GEORGE",
"favorite_cars" : [ "honda","Hyundae" ]
}
每当我在搜索最喜欢的汽车是丰田的人时查询此数据时,它都会返回此数据
{
"name" : "ABC",
"favorite_cars" : [ "ferrari","toyota" ]
}, {
"name" : "ABC",
"favorite_cars" : [ "ferrari","toyota" ]
}
结果是两条名为 ABC 的记录。如何仅选择不同的文档?我想得到的结果只是这个
{
"name" : "ABC",
"favorite_cars" : [ "ferrari","toyota" ]
}
这是我的查询
{
"fuzzy_like_this_field" : {
"favorite_cars" : {
"like_text" : "toyota",
"max_query_terms" : 12
}
}
}
我正在使用ElasticSearch 1.0.0。使用 java api 客户端