Painless script_field returns just that field in query result?

I don't see any mention in the docs about this.

When using a script_field, only that field is returned in the results, not with the rest of the document, I have to add includes to get the rest of the fields?

 GET data/_search
 {
   //"_source": { "includes": ["*"]},
   "query": {"match_all": {}},
   "script_fields" : {
         "new_field" : {
             "script" : {
                 "source": "'hello'"
             }
         }
   }
 }

Results:

 {
         "_index" : "data",
         "_type" : "_doc",
         "_id" : "1",
         "_score" : 1.0,
         "fields" : {
           "new_field" : [
             "hello"
           ]
         }
       },

We should certainly document that. I think the idea is that we default to fetching source but if you ask for something we figure you ask for everything you want.

Could you file an issue asking to update the docs? Or open a PR of you are feeling adventurous.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.