# How to solve json\_e\_o\_f\_exception on \_msearch /template

**URL:** <https://discuss.elastic.co/t/how-to-solve-json-e-o-f-exception-on-msearch-template/163514>\
**Category:** Elasticsearch\
**Created:** [January 9, 2019, 11:05am UTC](https://discuss.elastic.co/t/how-to-solve-json-e-o-f-exception-on-msearch-template/163514 "2019-01-09T11:05:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nico92](https://avatars.discourse-cdn.com/v4/letter/n/a87d85/32.png) [@Nico92](https://discuss.elastic.co/u/Nico92)\
**Post date:** [January 9, 2019, 11:05am UTC](https://discuss.elastic.co/t/how-to-solve-json-e-o-f-exception-on-msearch-template/163514/1 "2019-01-09T11:05:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [January 9, 2019, 11:11am UTC](https://discuss.elastic.co/t/how-to-solve-json-e-o-f-exception-on-msearch-template/163514/2 "2019-01-09T11:11:31Z")

</div>

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 🙂 )

---

<div class="post-metadata">

**Author:** ![Nico92](https://avatars.discourse-cdn.com/v4/letter/n/a87d85/32.png) [@Nico92](https://discuss.elastic.co/u/Nico92)\
**Post date:** [January 9, 2019, 1:00pm UTC](https://discuss.elastic.co/t/how-to-solve-json-e-o-f-exception-on-msearch-template/163514/3 "2019-01-09T13:00:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 6, 2019, 1:00pm UTC](https://discuss.elastic.co/t/how-to-solve-json-e-o-f-exception-on-msearch-template/163514/4 "2019-02-06T13:00:53Z")

</div>

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