Skip to content

Add source to inner_hits #1083

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

Closed
wants to merge 2 commits into from
Closed

Conversation

eliskah
Copy link

@eliskah eliskah commented Nov 11, 2020

This PR should fix following:

When using field collapsing, it is possible to define _source for inner hits, like this:

{
  "collapse": {
    "field" : "user_id",
    "inner_hits" : {
      "name" : "records",
      "size" : 5,
      "_source" : ["content", "updated_at"]
    }
  },
  "_source" : false,
  "size" : 10
}

DSL supports collapsing with inner hits fine, but if I try to define the _source inside the inner_hits block, it's used in the top level _source instead. See this example:

require 'json'
require 'elasticsearch/dsl'

include Elasticsearch::DSL

definition = search do
  collapse :user_id do
    inner_hits :records do
      size 5
      _source ["content", "updated_at"]
    end
  end
  _source false
  size 10
end

puts definition.to_hash.to_json

Returns:

{
  "size": 10,
  "collapse": {
    "field": "user_id",
    "inner_hits": {
      "name": "records",
      "size": 5
    }
  },
  "_source": [
    "content",
    "updated_at"
  ]
}

I would expect to get the query as above: With top level _source value of false and inner hits level _source with the fields "content" and "updated_at".

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@eliskah
Copy link
Author

eliskah commented Dec 10, 2020

Hi @picandocodigo! Please, have you had a chance to look at the PR? I am happy to add anything that would be missing or amend unclear or wrong stuff 😄

@picandocodigo
Copy link
Member

Hi @eliskah, thanks for this contribution and sorry about the delay! I've been busy with other priorities but I'll take a look at this as soon as possible. Thanks!

@eliskah
Copy link
Author

eliskah commented Dec 10, 2020

@picandocodigo thank you!

@picandocodigo
Copy link
Member

Transferred to the new repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants