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 –