wildcard查询
允许使用通配符*和来进行查询
*代表0个或多个字符
工代表任意1个字符
GET /ib3/user/ search { “query”: { “wildcard”:{ “name”: *zhao* }}}
GET /ib3/user/ search { “query”: { “wildcard”:{ *name": “Iii”}}}
#wildcard查询允许使用通配符*和?来进行查询
# * 代表0个或多个字符
# ? 代表任意1个字符
GET /lib3/user/_search
{
"query": {
"wildcard":{ "name":"zhao*"}
}
}
{
"took" : 1989,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [
{
"_index" : "lib3",
"_type" : "user",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"name" : "zhaoming",
"address" : "bei jing hai dian qu qing he zhen",
"age" : 20,
"birthday" : "1998-10-12",
"interests" : "xi huan hejiu, duanlian, changge"
}
},
{
"_index" : "lib3",
"_type" : "user",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"name" : "zhaoliu",
"address" : "hei long jiang sheng tie ling shi",
"age" : 50,
"birthday" : "1970-12-12",
"interests" : "xi buan hejiu, duanlian, lvyou"
}
}
]
}
}
GET /lib3/user/_search
{
"query": {
"wildcard": { "name": "li?i"}
}
}
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "lib3",
"_type" : "user",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"name" : "lisi",
"address" : "bei jing hai dian qu qing he zhen",
"age" : 23,
"birthday" : "1998-10-12",
"interests" : "xi huan hejiu,duanlian, changge"
}
}
]
}
}
本文介绍了如何使用通配符*和?进行有效查询,并通过具体示例展示了查询过程及结果,帮助读者理解通配符查询的基本原理。
&spm=1001.2101.3001.5002&articleId=123735450&d=1&t=3&u=b1824d4d70234dfebe734e6f49ae12d5)
616

被折叠的 条评论
为什么被折叠?



