0
我有日期字段在我的映射和我想要做的模糊搜索,在我的领域 下面是我的代码模糊日期型提起
GET _search
{
"query": {
"fuzzy": {
"death_date": {
"value": "3548"
}
}
}
}
当前结果不返回基于按预期数据。 虽然我有3548值它的得分是出现在结果 的顶部小于3549的值我已经改变了我的查询,包括参数范围内的建议
GET _search
{
"query" : {
"bool": {
"must":
{
"match": {
"marriages.marriage_year": "1630"
}
},
"should":
{
"match": {
"first_name":
{ "query" : "mary",
"fuzziness":"2"
}
}
},
"must":
{
"range" : {
"marriages.marriage_year": {
"gt" : "1620",
"lte" : "1740"
}
}
}
}
}
}
它返回与marriages.marriage_year数据=“ 1630“,玛丽作为第一名作为最高得分。我也想包括1620-1740之间的marriages.marriage_year,结果中没有显示。它仅显示marraige_year的数据1630
模糊在'日期'字段上没有意义。您可能要查找的是“范围”查询:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html#ranges-on-dates –