Complex or&missing search

Hello,

I'm trying to perform a query to obtain all the indexed resources that have
a particular value for a property or do not have a value for that property.
It can be generalized to obtaining all the resources that have the value
for a property in a list of values or they do not have a value for that
property.
I tried to do it with filters but it didn't seem to work:
"query": {

"filtered" : {

"query" : {"match_all":{}},

"filter" : {

"or" : [

{ "term" : {"property":"value"}},

{"missing" : {"field":"property"}}

]

}

}

}
I also thought about bool-should queries but I do not know how to use the
missing filter in it.

Can anyone tell me why my query is wrong and how can I write a proper one?

Thanks,
Iulia

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Your query looks fine. Are you getting no results or incorrect results?

Here is a version with a bool filter:

{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"should": [
{
"term": { "property": "value" }
},
{
"missing": { "field": "user" }
}
]
}
}
}
}
}

Ivan

On Wed, Oct 23, 2013 at 1:53 AM, Iulia Pasov iulia.pasov@gmail.com wrote:

Hello,

I'm trying to perform a query to obtain all the indexed resources that
have a particular value for a property or do not have a value for that
property. It can be generalized to obtaining all the resources that have
the value for a property in a list of values or they do not have a value
for that property.
I tried to do it with filters but it didn't seem to work:
"query": {

"filtered" : {

"query" : {"match_all":{}},

"filter" : {

"or" : [

{ "term" : {"property":"value"}},

{"missing" : {"field":"property"}}

]

}

}

}
I also thought about bool-should queries but I do not know how to use the
missing filter in it.

Can anyone tell me why my query is wrong and how can I write a proper one?

Thanks,
Iulia

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks Ivan. I thought I was getting incorrect results, but in fact
somebody else was indexing data at the same time.

On Wednesday, October 23, 2013 11:53:35 AM UTC+3, Iulia Pasov wrote:

Hello,

I'm trying to perform a query to obtain all the indexed resources that
have a particular value for a property or do not have a value for that
property. It can be generalized to obtaining all the resources that have
the value for a property in a list of values or they do not have a value
for that property.
I tried to do it with filters but it didn't seem to work:
"query": {

"filtered" : {

"query" : {"match_all":{}},

"filter" : {

"or" : [

{ "term" : {"property":"value"}},

{"missing" : {"field":"property"}}

]

}

}

}
I also thought about bool-should queries but I do not know how to use the
missing filter in it.

Can anyone tell me why my query is wrong and how can I write a proper one?

Thanks,
Iulia

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.