Match specific value or empty

I'm a bit new to this, but I'm trying to figure out how to write a query
for a field that gets all results that either match a specific string, or
have that field blank. I seem to be able to do one or the other, but not
both. Is there a solution to this?

Thanks,
Greg

--

hey greg:

this should do the job:

{
"bool" : {
"should" : { "term" : { "yourfield" : "yourvalue" }},
"should" : { "constant_score" : { "filter" : { "missing" : { "field" : "yourfield" }}}} }
}

simon
On Saturday, November 3, 2012 12:51:50 PM UTC+1, Greg H wrote:

I'm a bit new to this, but I'm trying to figure out how to write a query
for a field that gets all results that either match a specific string, or
have that field blank. I seem to be able to do one or the other, but not
both. Is there a solution to this?

Thanks,
Greg

--