Question about filtering on a nested type

I'm having trouble constructing a filter on a nested type in a document and
was wondering if anyone had any pointers or suggestions:

--
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.

Why shouldn't the filter match both documents? Both of them contain a
nested document that satisfies the query/filter. Note that elasticsearch
will return the entire contents of the parent document, which will include
all of the nested documents.

--
Ivan

On Wed, Jul 10, 2013 at 10:03 AM, adama adama@gadventures.com wrote:

I'm having trouble constructing a filter on a nested type in a document
and was wondering if anyone had any pointers or suggestions:
https://gist.github.com/Coalpaw/7cae7ff9cfcc555cb9ee

--
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.

Hello.

If i correctly understood your probleme, I think I would solve it with a
"nested filter" encapsulating an "and filter" encapsulating two "range
filters"
Le mercredi 10 juillet 2013 19:03:43 UTC+2, Adam A. a écrit :

I'm having trouble constructing a filter on a nested type in a document
and was wondering if anyone had any pointers or suggestions:
https://gist.github.com/Coalpaw/7cae7ff9cfcc555cb9ee

--
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.

Ivan,

Thanks for replying. The filter I included should indeed match both docs,
but the behaviour I am looking for is a filter that would only examine an
individual date's start and end ... essential treating each nested date as
a data set. To put it another way, I want to find any departures that have
a single date with a start gte some_date and an end date lte some_date.

Adam

On Wednesday, 10 July 2013 23:18:25 UTC-4, Ivan Brusic wrote:

Why shouldn't the filter match both documents? Both of them contain a
nested document that satisfies the query/filter. Note that elasticsearch
will return the entire contents of the parent document, which will include
all of the nested documents.

--
Ivan

On Wed, Jul 10, 2013 at 10:03 AM, adama <ad...@gadventures.com<javascript:>

wrote:

I'm having trouble constructing a filter on a nested type in a document
and was wondering if anyone had any pointers or suggestions:
https://gist.github.com/Coalpaw/7cae7ff9cfcc555cb9ee

--
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 elasticsearc...@googlegroups.com <javascript:>.
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.

Hey DH,

I figured I probably have to use an "and" filter somewhere but part of my
problem is I am having difficulty figuring out how the nesting works with
the query dsl. I did try this:

{
"query": {
"filtered": {
"query": {"match_all": {}},
"filter": {
"nested": {
"path": "dates",
"query": {
"filtered": {
"query": {"match_all": {}},
"filter": {
"and": [
{"range": {"dates.starts": {"gte":
"2013-11-11"}}},
{"range": {"dates.ends": {"lte":
"2013-12-05"}}}
]
}
}
}
}
}
}
}
}

but that just gave me the same results as the original filtered query.

Adam

On Thursday, 11 July 2013 08:35:01 UTC-4, DH wrote:

Hello.

If i correctly understood your probleme, I think I would solve it with a
"nested filter" encapsulating an "and filter" encapsulating two "range
filters"
Le mercredi 10 juillet 2013 19:03:43 UTC+2, Adam A. a écrit :

I'm having trouble constructing a filter on a nested type in a document
and was wondering if anyone had any pointers or suggestions:
https://gist.github.com/Coalpaw/7cae7ff9cfcc555cb9ee

--
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.

Yes, indeed.

You got both documents back because your filtered query filter containing
the dates filters brings back all the docs (build on a match_all query)
thats have both dates, not on a per nested doc basis .
Then, you put that in a nested filter but the damage has been done already.
Sorry if I am not clear, english is not my first language.

Try this instead :

{
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"nested" : {
"filter" : {
"and" : {
"filters" : [{
"range" : {
"dates.starts" : {
"gte" : "2013-11-11"
}
}
}, {
"range" : {
"dates.ends" : {
"lte" : "2013-12-05"
}
}
}

  ]
 }
},
"path" : "dates"

}
}
}
}

Le mercredi 10 juillet 2013 19:03:43 UTC+2, Adam A. a écrit :

I'm having trouble constructing a filter on a nested type in a document
and was wondering if anyone had any pointers or suggestions:
https://gist.github.com/Coalpaw/7cae7ff9cfcc555cb9ee

--
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.