Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support min_children and max_children on has_child query/filter #6019

Closed
clintongormley opened this issue May 2, 2014 · 3 comments
Closed
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v1.3.0 v2.0.0-beta1

Comments

@clintongormley
Copy link

Currently it is very difficult and inefficient to write a query like:

where parent has at least 5 matching children

The only way to do it is to:

  • use a has_child query with an inner constant_score and score_mode of sum
  • wrap in a function_score that resets the _score to zero if the min count is not achieved
  • do similar score calculations for all other clauses in the query
  • apply a min_score parameter to the overall query

It would be much more efficient to be able to say:

{
  "has_child": {
    "type": "foo",
    "minimum_should_match": 5,
    "query": {...some query...}
  }
}

Hopefully this could be applied to filters as well as queries?

/cc @martijnvg

@uboness
Copy link
Contributor

uboness commented May 2, 2014

+1 I like it

@martijnvg martijnvg self-assigned this May 15, 2014
@martijnvg martijnvg removed the review label May 15, 2014
@martijnvg martijnvg removed their assignment May 15, 2014
@dakrone dakrone added the v2.0.0 label May 19, 2014
clintongormley added a commit that referenced this issue May 30, 2014
Added support for min_children and max_children parameters to
the has_child query and filter. A parent document will only
be considered if a match if the number of matching children
fall between the min/max bounds.

Closes #6019
@clintongormley clintongormley changed the title Support minimum_should_match on has_child and nested queries Parent/Child: Support min_children and max_children on has_child query/filter Jul 16, 2014
@jsuchal
Copy link

jsuchal commented Mar 5, 2015

@clintongormley sorry for bumping this, but is this possible with nested docs?

@clintongormley
Copy link
Author

@jsuchal currently not - this is a change that would have to go into Lucene, I believe. But you could open a separate issue requesting it if you like

@clintongormley clintongormley changed the title Parent/Child: Support min_children and max_children on has_child query/filter Support min_children and max_children on has_child query/filter Jun 7, 2015
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Parent/Child labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v1.3.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants