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 the 'fields' option in inner_hits and top_hits. #62259

Merged
merged 3 commits into from
Sep 14, 2020

Conversation

jtibshirani
Copy link
Contributor

@jtibshirani jtibshirani commented Sep 10, 2020

This PR adds support for the 'fields' option in the following places:

  • Anytime inner_hits is used, for both fetching nested/ child docs and field collapsing
  • The top_hits aggregation

Addresses #61949.

@jtibshirani
Copy link
Contributor Author

jtibshirani commented Sep 10, 2020

Here's an example mapping and search request.

PUT test
{
  "mappings": {
    "properties": {
      "object": {
        "type": "nested",
        "properties": {
          "field": {
            "type": "keyword"
          }
        }
      }
    }
  }
}

POST test/_search
{
  "query": {
    "nested": {
      "query": { "match_all": {} },
      "path": "field",
      "inner_hits": {
        "_source": false,
        "fields": ["object.field"]
      }
    }
  }
}

Note that the full path to the field must be specified (object.field), which matches the behavior for docvalue_fields.

@jtibshirani jtibshirani marked this pull request as ready for review September 10, 2020 22:34
@jtibshirani jtibshirani added :Search/Search Search-related issues that do not fall into other categories >enhancement v7.10.0 v8.0.0 labels Sep 10, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Search)

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Sep 10, 2020
Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jtibshirani jtibshirani merged commit f29c743 into elastic:master Sep 14, 2020
@jtibshirani jtibshirani deleted the fields-inner-hits branch September 14, 2020 17:09
jtibshirani added a commit to jtibshirani/elasticsearch that referenced this pull request Sep 14, 2020
This PR adds support for the 'fields' option in the following places:
* Anytime `inner_hits` is used, for both fetching nested/ child docs and field collapsing
* The `top_hits` aggregation

Addresses elastic#61949.
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 Team:Search Meta label for search team v7.10.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants