Multiple document handling


(Ibrahim Diop) #1


I'm trying to use the index action, and I'm trying to save the multiple documents returned by my search.
For that I use the transform feature and I'm attempting to return the multiple document like this:

"index_payload" : { 
    "transform": {
      "script" : "return [_doc : ctx.payload.hits.hits]"
    "index" : {
      "index" : "test_index", 
      "doc_type" : "array" 

This doesn't work and I'm getting the following error:

      "id": "index_payload",
      "type": "index",
      "status": "failure",
      "reason": "NullPointerException[null]"

Any ideas?

(Alexander Reelsen) #2


a couple of follow up question to narrow down your problem

  1. What is the Elasticsearch version you are using?
  2. Is there any additional output in the master node log file?
  3. Does your search contain hits?
  4. Can you paste the output of the execute watch API here?
  5. Are you sure you want to index each element of the hits array as own document and not the _source field inside of each hit?


(Ibrahim Diop) #3

Thanks for your reply. Here are the details:

  1. ElasticSearch version: 2.4.1 (Elastic Cloud)
  2. Not sure I have access to that file...
  3. Yes, the search does contain hits
  4. Execute watch output:

  1. I think the _source field of each hits would be ideal.


(Alexander Reelsen) #4


I dont have access to that google doc, can you please use something, that can handle text easier, like a pastebin or a gist?


(Ibrahim Diop) #5

Sorry, there you go:

(Alexander Reelsen) #6


ok this does not yield anything useful either. If you are on cloud, can you please use the "Logs" console of your cluster and search for exceptions there?

Also, can you provide the full watch somewhere, so I can try to reproduce?


(system) #7