I am running a simple query like so:
{ "query": { "term": { "statuses": "active" } }, "script_fields": { "test": { "script": "_source.name" } } }
The problem is that once I introduce the script_fields
, I no longer get _source
in my results.
I have tried:
{ "fields": [ "_all" ], "query": { "term": { "statuses": "active" } }, "script_fields": { "email": { "script": "_source.name" } } }
and
{ "fields": [ "*" ], "query": { "term": { "statuses": "active" } }, "script_fields": { "email": { "script": "_source.name" } } }
But they did not make any difference. Is there a way to get _source
returned in addition to the script_fields
?
You can use the search API to search and aggregate data stored in Elasticsearch data streams or indices. The API's query request body parameter accepts queries written in Query DSL. The following request searches my-index-000001 using a match query. This query matches documents with a user.id value of kimchy .
Fields are the smallest individual unit of data in Elasticsearch. These are customizable and could include, for example: title, author, date, summary, team, score, etc. Each field has a defined datatype and contains a single piece of data.
In the fields
array, make it load _source
:
{ "stored_fields": [ "_source" ], "query": { "term": { "statuses": "active" } }, "script_fields": { "email": { "script": "_source.name" } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With