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 search fields API in SearchSource #77300

Closed
kertal opened this issue Sep 14, 2020 · 1 comment
Closed

Support search fields API in SearchSource #77300

kertal opened this issue Sep 14, 2020 · 1 comment

Comments

@kertal
Copy link
Member

kertal commented Sep 14, 2020

To allow SearchSource consumers like Discover to support runtime fields (#77107), SearchSource needs to allow usage of the search-fields API of Elasticsearch

https://www.elastic.co/guide/en/elasticsearch/reference/master/search-fields.html

In the SearchSource source code fields is already taken:

And this fields target stored_fields, this can't just be switched to the ES search fields, since it's not compatible.

if (fields) {
// filter out the docvalue_fields, and script_fields to only include those that we are concerned with
body.docvalue_fields = filterDocvalueFields(body.docvalue_fields, fields);
body.script_fields = pick(body.script_fields, fields);
// request the remaining fields from both stored_fields and _source
const remainingFields = difference(fields, keys(body.script_fields));
body.stored_fields = remainingFields;
setWith(body, '_source.includes', remainingFields, (nsValue) =>
isObject(nsValue) ? {} : nsValue
);
}

In the POC of #75407 this was solved by introducing a new SearchSource fields called fieldsApi, but this should be solved in a developer friendly, documented and tested way, not as a workaround.

@kertal
Copy link
Member Author

kertal commented Sep 14, 2020

Closing in favor of #77241

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

No branches or pull requests

1 participant