Hi,
My mapping looks like this:
address text
author text
category text
description text
type text
Where type can be a Collection, Content, Event, Tool.
How can I make sure query will return at least 4 of each tools, events, collections and contents.
Hi,
My mapping looks like this:
address text
author text
category text
description text
type text
Where type can be a Collection, Content, Event, Tool.
How can I make sure query will return at least 4 of each tools, events, collections and contents.
You can use a simple terms aggregation [1], with a filter aggregation [2]
on the types requested and then select the top 4 inner hits [3].
[1]
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
[2]
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html
[3]
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
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.