gpt4 book ai didi

elasticsearch - Elasticsearch在匹配查询中给出不必要的记录

转载 作者:行者123 更新时间:2023-12-02 22:29:14 25 4
gpt4 key购买 nike

我想获取所有dateofbirth具有子字符串“-11-09”的文档。

这是我的elasticsearch查询:

{ "query": { "bool" : { "must": { "match": { "dobdata": ".*-11-09.*"} } } } }

我得到的结果是
{
"took": 8,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 4,
"max_score": 5.0782137,
"hits": [
{
"_index": "userindexv1",
"_type": "usertype",
"_id": "58f9a9d1acf8c47037000038",
"_score": 5.0782137,
"_source": {
"fullname": "Eshwar ",
"fullname_raw": "Eshwar ",
"mobile1": "7222222256",
"uid": "UIDS1010",
"mobile2": "",
"classname": "Class 5",
"classname_raw": "Class 5",
"divid": 63,
"category": "S",
"dobdata": "2010-11-09"
}
},
{
"_index": "userindexv1",
"_type": "usertype",
"_id": "57960b35acf8c4c43000002c",
"_score": 1.259227,
"_source": {
"fullname": "Sindhu ",
"fullname_raw": "Sindhu ",
"mobile1": "9467952335",
"uid": "UIDS1006",
"mobile2": "",
"classname": "class 1s Group for class g",
"classname_raw": "class 1s Group for class g",
"divid": 63,
"category": "S",
"dobdata": "2012-11-08"
}
},
{
"_index": "userindexv1",
"_type": "usertype",
"_id": "58eb62d2acf8c4d43300002f",
"_score": 1.1471639,
"_source": {
"fullname": "Himanshu ",
"fullname_raw": "Himanshu ",
"mobile1": "9898785484",
"uid": "",
"mobile2": "",
"classname": "Play Group",
"classname_raw": "Play Group",
"divid": 63,
"category": "S",
"dobdata": "2012-11-08"
}
},
{
"_index": "userindexv1",
"_type": "usertype",
"_id": "580dbe5bacf8c4b82300002a",
"_score": 1.1471639,
"_source": {
"fullname": "Sai Bhargav ",
"fullname_raw": "Sai Bhargav ",
"mobile1": "9739477159",
"uid": "",
"mobile2": "7396226318",
"classname": "class 1s Group for class g",
"classname_raw": "class 1s Group for class g",
"divid": 63,
"category": "S",
"dobdata": "2012-11-07"
}
}
]
}}

我正在获取其dateofbirth不包含字符串“-11-09”的记录。我试图解决它。我找不到灵魂。

我是Elasticsearch的新手。我只想要第一张唱片。谁能帮我一下。对不起,英语不好。

最佳答案

甚至我也遇到了同样的问题,并且通过做两件事解决了它。
1.将出生日期的格式从Y-m-d更改为YMd,并使索引为not_analyzed。
2.使用通配符查询代替匹配查询

{
"query": {
"wildcard": {
"dobdata": {
"value": "*Nov09*"
}
}
}
}

它解决了我的问题。希望这也能解决您的问题。

关于elasticsearch - Elasticsearch在匹配查询中给出不必要的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47216939/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com