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

Feature request: minimum_nested_match #32165

Closed
robtesch opened this issue Jul 18, 2018 · 2 comments
Closed

Feature request: minimum_nested_match #32165

robtesch opened this issue Jul 18, 2018 · 2 comments
Labels
:Search/Search Search-related issues that do not fall into other categories team-discuss

Comments

@robtesch
Copy link

robtesch commented Jul 18, 2018

Describe the feature:

I would love to see an option of a nested query where instead of returning parent docs where any nested doc matches a nested query, there could be an option to return only parent docs when some minimum number of nested docs matched. Similar to the way we set up minimum_should_match. In my particular case I would want to only return parent docs where ALL the nested docs match a specific query.

Example:

PUT test
{
  "mappings": {
    "_doc": {
      "properties": {
        "comments": {
          "type": "nested"
        }
      }
    }
  }
}
PUT test/_doc/1?refresh
{
  "title": "Test title",
  "comments": [
    {
      "author": "kimchy",
      "number": 1
    },
    {
      "author": "nik9000",
      "number": 2
    }
  ]
}
PUT test/_doc/2?refresh
{
  "title": "Test title 2",
  "comments": [
    {
      "author": "kimchy",
      "number": 1
    },
    {
      "author": "kimchy",
      "number": 2
    }
  ]
}

Then, in order to only match doc 2, where all the nested docs match the query:

POST test/_search
{
  "query": {
    "nested": {
      "path": "comments",
      "query": {
        "match": {"comments.author" : "kimchy"}
      },
      "minimum_nested_match": "100%",
    }
  }
}

Perhaps there is already some way of doing this that I don't know about?

@martijnvg martijnvg added :Search/Search Search-related issues that do not fall into other categories team-discuss labels Jul 18, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@jpountz
Copy link
Contributor

jpountz commented Jul 30, 2018

Closing in favor of #10043.

@jpountz jpountz closed this as completed Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Search/Search Search-related issues that do not fall into other categories team-discuss
Projects
None yet
Development

No branches or pull requests

4 participants