这是我的JSON。
{
"id":100,
"name":"xxx",
"hobbies":["cricket","footbal","singing & dancing"]
}
我需要从“其他”过滤“唱歌和跳舞”字符串。在下面的查询中执行。
http://localhost:9200/employeed/data/_search?q={"query":{"query_string":{"query" : "hobbies:Singing & dancing"}}}
我在异常(exception)之下。
"type": "illegal_argument_exception",
"reason": "request [employee/data/_search] contains unrecognized parameter: [ Singing\"}}}]"
有什么帮助吗?
最佳答案
您正在尝试通过URI发送DSL查询。两者不要混用,请参见此处:https://www.elastic.co/guide/en/elasticsearch/reference/6.2/search-search.html
The search API allows you to execute a search query and get back search hits that match the query. The query can either be provided using a simple query string as a parameter, or using a request body.
您可以使用DSL并将其发送到请求正文中,也可以更改URL以仅包括要使用的兴趣爱好query_string。像这样:
http://localhost:9200/employeed/data/_search?q=hobbies%3A%5C%22Singing%20%26%20dancing%5C%22
query_string部分也是URL编码的。我还在您的搜索值周围添加了引号,否则将对它们进行“或”运算。未编码的版本:
hobbies:\"Singing & dancing\"
关于hadoop - Elasticsearch -使用查询UI搜索完全匹配的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48926849/