elasticsearch - 如何将 Kibana 查询转换为“elasticsearch_dsl”查询
问题描述
我有一个查询
GET index/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"key1": "value"
}
},
{
"wildcard": {
"key2": "*match*"
}
}
]
}
}
}
我想用elasticsearch_dsl
我试过的包打同样的电话
s = Search(index=index).query({
"bool": {
"should": [
{
"match": {
"key1": "value"
}
},
{
"wildcard": {
"key2": "*match*"
}
}
]
}
})
s.using(self.client).scan()
但是结果不一样,我在这里遗漏了什么吗
有没有办法用elasticsearch_dsl
这个来表示我的查询,没有结果
s = Search(index=index).query('wildcard', key2='*match*').query('match', key1=value)
s.using(self.client).scan()
解决方案
这个查询对我有用
s = Search(index=index).query('match', key1=value)
.query('wildcard', key2='*match*')
.source(fields)
此外,如果键具有_
类似key_1
弹性搜索的行为不同并且查询匹配结果,即使与您的查询不匹配。所以尽量选择你key
没有下划线的。
推荐阅读
- c# - 在控制台应用程序中使用秒表
- github-api - 为什么 Github api 不只提供受保护的分支?
- spring-boot - 如何在java中将base64转换为MultipartFile
- html - 右不工作,但左在位置:绝对;
- encoding - 为什么在编码为 H264 时会丢失 PTS 信息?
- javascript - Flask - Javascript 和 CSS 未正确呈现
- amazon-web-services - 通过 AWS Step Functions 调用 AWS Lambda?
- database - 如何在子查询(MariaDB)中使用主查询中的值
- css - 使用 CSS 禁用顶部菜单上的悬停效果
- wpf - VB.net 在单击按钮时使用 IDataErrorInfo 验证文本框