How to solve json_e_o_f_exception on _msearch /template

Hey guys,

I'm trying so use Multisearch API. But I got an bad json eof exception.

Here is my case:

How I build my template:

POST _scripts/t1
{
  "script": {
    "lang": "mustache",
    "source": {
      "query": {
        "match_phrase": {
          "{{field}}": "{{value}}"
        }
      }
    }
  }
}

So I looked at my template

GET _scripts/t1
Returns:
{
  "_id": "t1",
  "found": true,
  "script": {
    "lang": "mustache",
    "source": """{"query":{"match_phrase":{"{{field}}":"{{value}}"}}}""",
    "options": {
      "content_type": "application/json; charset=UTF-8"
    }
  }
}

So now I want to get results with:

POST processlog/_msearch/template
{}
{
  "id": "t1",
  "params": {
    "field": "Envrionment",
    "value": "Test"
  }
}
{}
{
  "id": "t1",
  "params": {
    "field": "Envrionment",
    "value": "Integration"
  }
}

I got the exception:

{
  "error": {
    "root_cause": [
      {
        "type": "json_e_o_f_exception",
        "reason": "Unexpected end-of-input: expected close marker for Object (start marke                   r at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@71                   7c0d8d; line: 1, column: 1])\n at [Source: org.elasticsearch.transport                  .netty4.ByteBufStreamInput@717c0d8d; line: 2, column: 3]"
      }
    ],
    "type": "json_e_o_f_exception",
    "reason": "Unexpected end-of-input: expected close marker for Object (start marke                   r at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@71                   7c0d8d; line: 1, column: 1])\n at [Source: org.elasticsearch.transport                  .netty4.ByteBufStreamInput@717c0d8d; line: 2, column: 3]"
  },
  "status": 500
}

Whats wrong in my case?
Thanks for helping me guys

Each item that you pass to _msearch/template should be on a single line, but it looks like you are including extra line breaks.

(also, we're not all guys :slight_smile: )

Thank you it worked :slight_smile:
But with many params it becomes fast unreadable.

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