# Unable to execute mtermvectors elasticsearch query from AWS EMR cluster using Spark

**URL:** <https://discuss.elastic.co/t/unable-to-execute-mtermvectors-elasticsearch-query-from-aws-emr-cluster-using-spark/240819>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [July 12, 2020, 5:22am UTC](https://discuss.elastic.co/t/unable-to-execute-mtermvectors-elasticsearch-query-from-aws-emr-cluster-using-spark/240819 "2020-07-12T05:22:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Salil\_Surendran](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/salil_surendran/32/71985_2.png) [@Salil\_Surendran](https://discuss.elastic.co/u/Salil_Surendran)\
**Post date:** [July 12, 2020, 5:22am UTC](https://discuss.elastic.co/t/unable-to-execute-mtermvectors-elasticsearch-query-from-aws-emr-cluster-using-spark/240819/1 "2020-07-12T05:22:10Z")

</div>

Hello,  
I am trying to execute this elasticsearch query via spark:

```
    POST /aa6/_mtermvectors  
    {
      "ids": [
        "ABC",
        "XYA",
        "RTE"
      ],
      "parameters": {
        "fields": [
          "attribute"
        ],
        "term_statistics": true,
        "offsets": false,
        "payloads": false,
        "positions": false
      }
    }

```

The code that I have written in Zeppelin is :

```
def createString():String = {
    return s"""_mtermvectors {
  "ids": [
    "ABC",
    "XYA",
    "RTE"
  ],
  "parameters": {
    "fields": [
      "attribute"
    ],
    "term_statistics": true,
    "offsets": false,
    "payloads": false,
    "positions": false
    }
  }"""
}

import org.elasticsearch.spark._
sc.esRDD("aa6", "?q="+createString).count   

```

I get the error :

org.elasticsearch.hadoop.rest.EsHadoopInvalidRequest: org.elasticsearch.hadoop.rest.EsHadoopRemoteException: parse\_exception: parse\_exception: Encountered " \<RANGE\_GOOP\> "["RTE","XYA","ABC" "" at line 1, column 22.  
Was expecting:  
"TO" ...

```
{"query":{"query_string":{"query":"_mtermvectors {\"ids\": [\"RTE\",\"ABC\",\"XYA\"], \"parameters\": {\"fields\": [\"attribute\"], \"term_statistics\": true, \"offsets\": false, \"payloads\": false, \"positions\": false } }"}}}
	at org.elasticsearch.hadoop.rest.RestClient.checkResponse(RestClient.java:477)
	at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:434)
	at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:428)
	at org.elasticsearch.hadoop.rest.RestClient.execute(RestClient.java:408)

```

This is probably something simple but I am unable to find a way to set the request body while making the spark call

---

<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:** [August 9, 2020, 5:22am UTC](https://discuss.elastic.co/t/unable-to-execute-mtermvectors-elasticsearch-query-from-aws-emr-cluster-using-spark/240819/2 "2020-08-09T05:22:24Z")

</div>

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