You could break the products into an arbitrary number of batches as follows
(in this case page 5 of 100):
{
"aggs":{
"productsPage":{
"terms":{
"script":"p=doc['product'].value;if(p.hashCode()%100==5)return p;return
null;"
}
}
}
}
On Wednesday, April 29, 2015 at 12:34:13 PM UTC+1, Zsolt wrote:
>
> Thanks Mark, this returns the desired results.
>
> Unfortunately it seems to have introduced a new issue. I don't have
> millions of products but enough so I use paging and as I can see, it is not
> possible to page/sort the returned buckets (issue 4915
> <https://github.com/elastic/elasticsearch/issues/4915>)...
>
> \Zsolt
>
> On Wednesday, 29 April 2015 10:24:04 UTC+2, [email protected] wrote:
>>
>> >I would like to return all products but only the customized version for
>> a product where it exists (where "owner" = "a-user-name").
>>
>> Search for:
>> user-name:(global OR john)
>> Combine this with a terms aggregation to break down by "product" field
>> and below that nest a "top_hits" aggregation with a size of 1.
>>
>> The search should naturally rank a match on a user name higher than a
>> match on "global" (assuming global is very common and per-user
>> customizations are rare).
>> Otherwise look into boosts.
>> The top_hits agg should then select the best-scoring option for each
>> product.
>>
>> Obviously if you have millions of products this could present a memory
>> issue.
>>
>> Cheers
>> Mark
>>
>
--
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/a995a89d-fab0-49f7-a378-5f13a3554a10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.