Text query on multiple fields

On Wed, 2012-03-14 at 09:44 -0700, Jan Fiedler wrote:

Well, not sure. This would use the default operator of the text query
(which is 'OR'). I have not tested it but I would assume I would end
up hitting documents that only have one of the terms (in either name
or title). What I need is documents that have both terms (i.e. 'foo'
and 'bar') in either the 'name' or the 'title' field.

:wink:

curl -XGET 'http://127.0.0.1:9200/_all/_search?pretty=1' -d '
{
"query" : {
"dis_max" : {
"queries" : [
{
"text" : {
"name" : {
"operator" : "and",
"query" : "foo bar"
}
}
},
{
"text" : {
"title" : {
"operator" : "and",
"query" : "foo bar"
}
}
}
]
}
}
}
'