There is always a "product" with "owner": "global" and only sometimes the
same product with different owner (basically a product is customized for a
user). I would like to return all products but only the customized version
for a product where it exists (where "owner" = "a-user-name"). So for the
my example I would like returned the following two docs:
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.
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.
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, ma...@elastic.co 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.
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, ma...@elastic.co 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.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.