So it’s another story here.

I think you must use in nested filter the full path to your field, including 
the nested field name.



-- 
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet <https://twitter.com/dadoonet> | @elasticsearchfr 
<https://twitter.com/elasticsearchfr> | @scrutmydocs 
<https://twitter.com/scrutmydocs>



> Le 9 janv. 2015 à 14:30, Dev Day <[email protected]> a écrit :
> 
> Hi David,
> 
> Thank you for your reply & help on this.
> 
> Initially I did try this approach, but it didn't work.
> However, in order to provide you an example, I created a very simple doc.
> When I did this, I could see it worked.
> The issue I had with my code was that there was a "price" price at the root 
> level as well as the variants level.
> I didn't think this would be an issue.
> 
> I have renamed the price node at the root level and this is now working as 
> desired.
> However, can you tell me why you cannot have keys of the same name in 
> different levels of a document?
> 
> Thank you,
> 
> Dev
> 
> 
> On Friday, January 9, 2015 at 1:09:05 PM UTC, David Pilato wrote:
> I think this should work:
> 
> "post_filter": {
>    "nested": {
>         "path": "variants",
>          "filter":{
>          "range": {"price":{ "gt": 20.0 }}
>          }
>      }
> }
> 
> --
> David ;-)
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 9 janv. 2015 à 14:00, Dev Day <[email protected] <javascript:>> a écrit :
> 
>> Hi,
>> 
>> I would like to run a post filter on a nested value, but cannot seem to get 
>> this working.
>> This is my very simple document structure:
>> 
>> {"code":"ABC", "variants": [{"sku":"123", "price": 15}], "colour":"blue"}
>> {"code":"DEF", "variants": [{"sku":"456", "price": 30}], "colour":"red"}
>> 
>> I have the following mapping
>> 
>> {"variants": {"type":"nested"}
>> 
>> Which gives me this when I query the mappings, so I know it's in place.
>> 
>> {"variants": {"type":"nested", "properties": { "price": { "type": "long"}}
>> 
>> I run a search to collate aggregations on the colour:
>> 
>> "aggs": { "colour": { "terms": { "field": "colour" } } }
>> 
>> This works a treat and I get Blue 1, and Red 1 returned.
>> 
>> I wanted to run a post filter on variants.price > 20.
>> I have tried
>> 
>>     "post_filter": {
>>             "range": {"variants.price":{ "gt": 20.0 }}
>>     }
>> 
>> And I get 0 results
>> I have also tried 
>> 
>> "post_filter": {
>>    "nested": {
>>         "path": "variants",
>>          "post_filter":{
>>          "range": {"price":{ "gt": 20.0 }}
>>          }
>>      }
>> }
>> 
>> But this crashes.
>> 
>> Can anyone help?
>> 
>> Regards,
>> Dev
>> 
>> -- 
>> 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 [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/elasticsearch/79b7583c-6336-495b-bef1-d9ba0a9e0b83%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/elasticsearch/79b7583c-6336-495b-bef1-d9ba0a9e0b83%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/elasticsearch/840c6b72-f689-4972-a7fe-91b8853ecc84%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/elasticsearch/840c6b72-f689-4972-a7fe-91b8853ecc84%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/31BEA447-5F60-47E9-A2BA-647EF30D86D0%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

Reply via email to