使用elasticsearch中的两个不同字段搜索查询

时间:2016-06-27 11:59:40

标签: elasticsearch querydsl

我需要在弹性搜索中搜索

select * from tablename where file.content='xyz' and filePermission.Id='abc'  

我需要添加什么查询。是否可以为搜索查询提供过滤器?我已将file.content设置为默认字段。

1 个答案:

答案 0 :(得分:1)

AND SQL查询可以写成“必须bool查询”:

{
    "query" : {
        "bool" : {
            "must" : [
                { "match" : { "file.content":"xyz"} },
                { "match" : { "filePermission.Id" : "abc"} }
            ]
        }
    }
}