如何在elasticsearch中使用Query DSL过滤掉带有单引号的字符串?
我必须使用 Query DSL 过滤掉带有单引号的字符串,例如 'lang': 'en'
。
我使用了以下查询:
{
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "message",
"query": "*\'lang'\: \'en\'*"
}
}
]
}
}
}
但它不起作用。
我还尝试使用双斜杠(\\
)字符来转义单引号('
),但它仍然不起作用。
I have to filter out a string with single quotes like 'lang': 'en'
using Query DSL.
I used the following query:
{
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "message",
"query": "*\'lang'\: \'en\'*"
}
}
]
}
}
}
But it's not working.
I also tried using double slash (\\
) character to escape the single quote ('
), but it's sill not working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少转义
冒号
。下面的查询将为您提供预期的结果:
另外,不要在查询的开始和结束处给出
*
。You are missing to escaping
colon
.Below query will give you expected result:
Also, dont give
*
in starting and ending of query.