Hi.

I tried to set the nested_path to "marketplaces" and "marketplaces.prices". 
But I still get "Infinity" as sort result. 

Best regards,
Elke

Am Freitag, 10. Oktober 2014 15:23:50 UTC+2 schrieb Jonathan Foy:
>
> I suspect that because you have multiple levels of nesting you need to use 
> the nested path 
> <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#_sorting_within_nested_objects>
>  
> (it's probably choosing marketplaces.prices, and you would want just 
> marketplaces, though I'm not positive).
>
> On Tuesday, October 7, 2014 11:35:37 AM UTC-4, Elke wrote:
>>
>> Hi.
>>
>> I have a question about sorting by nested fields. 
>> This is just an small example of the hierarchy level (The marketplaces 
>> and the prices are mapped as nested documents): 
>>
>> { id: "doc1",
>>   name : "test",
>>   marketplaces : [     { "name" :  "marketPlace1",
>>                       "prices" : [ { "amount": "20.00" },
>>                                 {  "amount": "40.00" }]
>>                     },
>>                      { "name" :  "marketPlace2",
>>                       "prices" : [{ "amount": "21.00" },
>>                                 { "amount": "30.00" }]
>>                     }]}
>>                     
>> { id: "doc2",
>>   name : "test2",
>>   marketplaces : [     { "name" :  "marketPlace1",
>>                       "prices" : [{ "amount": "30.00" },
>>                                 { "amount": "35.00" }]
>>                     },
>>                      { "name" :  "marketPlace2",
>>                       "prices" : [{ "amount": "1.00" },
>>                                 { "amount": "3.00" }]
>>                     }]}
>>                     
>> Now I want to search for all documents with the marketplace name : 
>> "marketPlace1" and sort the result by the prices.amount of this 
>> marketplace. 
>> So I expect that in the example the first document will be in first place 
>> and the second document will be in second place. 
>>
>> The filter works fine. I won't see the documents without "marketPlace1" 
>> in the result list. 
>> But the sort doesn't restrict the same as the filter. So I tried to set a 
>> nested filter to match the upper hierarchy too. 
>>
>> I tried this sort, but got the value "Infinity" as sort result. :
>>  "sort" :  {
>>     "marketplaces.prices.amount" : { "order" : "asc" , "nested_filter" : 
>> { 
>>                                     "term" : {
>>                                         "marketplaces.name" : 
>> "marketPlace1"
>>                                     }}}}
>>
>> In case I don't use the nested_filter I get the second document as first 
>> result, because the sorting doesn't consider the marketPlace name.         
>>                             
>>   
>> Is there a solution for my problem?
>> Thank you very much for your help. 
>>
>> Best regards, 
>> Elke
>>
>>
>>
>>                     
>>
>

-- 
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/57395623-eae8-4c02-b0f6-24f3e913f7ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to