>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 elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/dead03ff-3f0f-4217-b8de-2cde93ab4fdb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to