Class Group


  • public class Group
    extends DslCloneable
    Grouping parameters

    QueryDefinition.getGroupedQuery() and QueryDefinition.getGroupedFilters() could override main query and filter queries when selecting group details.

    Note: In order to use these features the documents must be located on the same shard. This could be achieved by restricting data collection to one shard, or by setting up Document Routing on indexing.

    The same shard restriction could be lifted with hint "hint.grouping.method=group". But getLeaderStrategy(), QueryDefinition.getGroupedQuery() and QueryDefinition.getGroupedFilters() will be ignored; and total number of groups will not be calculated.

    To calculate total number of group with "hint.grouping.method=group", another hint has to be specified: "hint.grouping.num.found=true", but this will require the documents to be located on the same shard too.

    • Constructor Detail

    • Method Detail

      • getField

        public java.lang.String getField()
        Returns:
        name of the field that will be used for grouping. Required.
      • getLeaderStrategy

        public GroupLeaderStrategy getLeaderStrategy()
        Returns:
        a strategy that is used to determine group head document. If no strategy specified highest scoring document is selected as the head document for a group.

        This field is ignored with "hint.grouping.method=group". "sort" leader strategy with getSort() order will be used.

      • getSort

        public java.util.List<SortElement> getSort()
        Returns:
        a sort order for group details
      • setSort

        public void setSort​(java.util.List<SortElement> sort)
      • getSize

        public java.lang.Long getSize()
        Returns:
        a number of group details to include. To only return header documents, set to 0. Default is 5.