gpt4 book ai didi

mysql - Elasticsearch : Find All Records By Single Phrase

转载 作者:行者123 更新时间:2023-11-29 12:21:53 25 4
gpt4 key购买 nike

我正在使用elastic-search-1.4.4。这是我的查询:

   { 
"query": {
"filtered": {
"filter": { "term": { "Name": "n" } }
}
}
}

这是我的索引文档:

   {
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 12,
"max_score" : 1.0,
"hits" : [ {
"_index" : "mytry",
"_type" : "users",
"_id" : "23",
"_score" : 1.0,
"_source":{"ID":23,"Name":"Abudul Rafay","Email":"a","Password":"afasd"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "28",
"_score" : 1.0,
"_source":{"ID":28,"Name":"helo","Email":"helo","Password":"heko"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "30",
"_score" : 1.0,
"_source":{"ID":30,"Name":"nup","Email":"nup","Password":"nup"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "31",
"_score" : 1.0,
"_source":{"ID":31,"Name":"apex","Email":"apex","Password":"apex"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "29",
"_score" : 1.0,
"_source":{"ID":29,"Name":"change","Email":"change","Password":"change"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "24",
"_score" : 1.0,
"_source":{"ID":24,"Name":"rafay","Email":"hello","Password":"fasfas"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "32",
"_score" : 1.0,
"_source":{"ID":32,"Name":"newtry","Email":"newtry","Password":"newtry"}
}, {
"index" : "mytry",
"_type" : "users",
"_id" : "25",
"_score" : 1.0,
"_source":{"ID":25,"Name":"r rafay ","Email":"r rafay","Password":"r rafay"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "19",
"_score" : 1.0,
"_source":{"ID":19,"Name":"n","Email":"a","Password":"a"}
}, {
"_index" : "mytry",
"_type" : "users",
"_id" : "26",
"_score" : 1.0,
"_source":{"ID":26,"Name":"New User","Email":"New","Password":"new"}
} ]
}
}

这是我运行上述查询后的结果:

     {
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "mytry",
"_type" : "users",
"_id" : "19",
"_score" : 1.0,
"_source":{"ID":19,"Name":"n","Email":"a","Password":"a"}
} ]
}
}

所以,我想获取名称字段中开始或包含单词“n”的所有记录。我尝试过聚合,但它不起作用。

最佳答案

您可以为此使用通配符查询。术语查询将检查完全匹配。

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html

关于mysql - Elasticsearch : Find All Records By Single Phrase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28879489/

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