[英]Multiple wildcards in one query in elasticsearch
curl localhost:9200/tweet/posts/_search -d '{
"query": {
"and": [
{
"wildcard": {
"_all": "*pet*"
}
},
{
"wildcard": {
"_all": "*rom*"
}
}
]
}
}'
This gives me a parse exception.这给了我一个解析异常。 I want to run a MySQL
like(%test%)
type query with an AND condition.我想运行一个带有 AND 条件的 MySQL
like(%test%)
类型的查询。 Is there any other good way to do in elasticsearch. elasticsearch有没有其他好的办法。
Maybe something like this? 也许是这样的?
{
"query": {
"bool": {
"must": [
{
"wildcard": {
"_all": {
"value": "*pet*"
}
}
},
{
"wildcard": {
"_all": {
"value": "*rom*"
}
}
}
]
}
}
}
dis_max query can support wildcard queries not a bool. dis_max 查询可以支持通配符查询而不是 bool。 Please take a look here: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html I would write something like this:
请看这里: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html我会这样写:
{
"query": {
"dis_max": {
"queries": [
{"wildcard": {
"_all": {"value" : "*pet*"}
}},
{"wildcard": {
"_all": {"value" : "*rom*"}
}}
]
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.