# Error while using query parameter in scroll api

**URL:** <https://discuss.elastic.co/t/error-while-using-query-parameter-in-scroll-api/32844>\
**Category:** Elasticsearch\
**Created:** [October 23, 2015, 11:17am UTC](https://discuss.elastic.co/t/error-while-using-query-parameter-in-scroll-api/32844 "2015-10-23T11:17:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AmitPandita](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@AmitPandita](https://discuss.elastic.co/u/AmitPandita)\
**Post date:** [October 23, 2015, 11:17am UTC](https://discuss.elastic.co/t/error-while-using-query-parameter-in-scroll-api/32844/1 "2015-10-23T11:17:08Z")

</div>

Hi Group,

I am using Elasticsearch Helpers Scan API to output all bulk records from my index.  
I wanted to use the query parameter to filter the certain records first and then use scan for which I referred to the standard doc for scan here . But as soon as I apply the query parameter it gives me a 400 error. Here is my line of code and error.

Script:

import elasticsearch  
import elasticsearch.exceptions  
import elasticsearch.helpers as helpers  
import time

es = elasticsearch.Elasticsearch(['54.151.244.153'],retry\_on\_timeout=True)

scanResp = helpers.scan(client=es,scroll="5m",query="{'match': {'channel\_id': '34'}}",index='stg-index',timeout="10m",size=500)

resp={}  
start\_time = time.time()  
for resp in scanResp:  
data = resp  
#print data.values()[3]

print("--- %s seconds ---" % (time.time() - start\_time))

Output:

RequestError: TransportError(400, u"SearchPhaseExecutionException[Failed to execute phase [init\_scan], all shards failed; shardFailures {[lEAncRHvQHKpPqlfw1NWEQ][stg-godam][0]: SearchParseException[[stg-godam][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{'match': {'channel\_id': '34'}}]]]; nested: JsonParseException[Unexpected character (''' (code 39)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@4cbfbcfa; line: 1, column: 3]]; }{[lEAncRHvQHKpPqlfw1NWEQ][stg-godam][1]: SearchParseException[[stg-godam][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{'match': {'channel\_id': '34'}}]]]; nested: JsonParseException[Unexpected character (''' (code 39)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@4cbfbcfa; line: 1, column: 3]]; }{[lEAncRHvQHKpPqlfw1NWEQ][stg-godam][2]: SearchParseException[[stg-godam][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{'match': {'channel\_id': '34'}}]]]; nested: JsonParseException[Unexpected character (''' (code 39)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@4cbfbcfa; line: 1, column: 3]]; }{[lEAncRHvQHKpPqlfw1NWEQ][stg-godam][3]: SearchParseException[[stg-godam][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{'match': {'channel\_id': '34'}}]]]; nested: JsonParseException[Unexpected character (''' (code 39)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@4cbfbcfa; line: 1, column: 3]]; }{[lEAncRHvQHKpPqlfw1NWEQ][stg-godam][4]: SearchParseException[[stg-godam][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{'match': {'channel\_id': '34'}}]]]; nested: JsonParseException[Unexpected character (''' (code 39)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [B@4cbfbcfa; line: 1, column: 3]]; }]")

Looked on the internet but not sure what I have done wrong here.

Any help is appreciated

---

<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:** [July 5, 2017, 11:43pm UTC](https://discuss.elastic.co/t/error-while-using-query-parameter-in-scroll-api/32844/2 "2017-07-05T23:43:03Z")

</div>


