Ajoe
Ajoe

Reputation: 1545

Search query with two different fields in elasticsearch

I need to search in elasticsearch like

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

What query I need to add. Is it possible to give a filter to search query? I have set file.content as a default field.

Upvotes: 0

Views: 82

Answers (1)

AND SQL queries can be written as a "must bool query":

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

Upvotes: 1

Related Questions