# SearchParseException JS client

**URL:** <https://discuss.elastic.co/t/searchparseexception-js-client/26532>\
**Category:** Elasticsearch\
**Created:** [July 29, 2015, 11:37pm UTC](https://discuss.elastic.co/t/searchparseexception-js-client/26532 "2015-07-29T23:37:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbbush](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jbbush](https://discuss.elastic.co/u/jbbush)\
**Post date:** [July 29, 2015, 11:37pm UTC](https://discuss.elastic.co/t/searchparseexception-js-client/26532/1 "2015-07-29T23:37:11Z")

</div>

I'm working on a JS client and having issues querying my index. I can use CURL to query it but my JS client fails to parse the query and I get the exception below. What am I doing wrong?

Version1:  
client.search(  
{  
index:'blog',  
q: 'user:dilbert'  
},  
function (err, resp)  
{  
if (err)  
{  
alert("Query Error: "+ err.message);  
}  
else  
{  
var hits = resp.body.hits;  
alert("hits = " + hits);  
}  
}  
);

Version2:  
client.search({  
index: 'blog',  
body: {  
query: {  
match: {  
body: 'dilbert'  
}  
}  
}  
}).then(function (resp) {  
var hits = resp.hits.hits;  
}, function (err) {  
alert(err.message);  
});

[2015-07-29 17:29:48,276][DEBUG][action.search.type] [Black Talon] [blog]  
[2], node[7P3BV3fuTJqRwvvc3Wmcvw], [P], s[STARTED]: Failed to execute [org.elast  
icsearch.action.search.SearchRequest@16ffd379] lastShard [true]  
org.elasticsearch.search.SearchParseException: [blog][2]: from[-1],size[-1]: Par  
se Failure [Failed to parse source [_na_]]  
at org.elasticsearch.search.SearchService.parseSource(SearchService.java  
:735)  
at org.elasticsearch.search.SearchService.createContext(SearchService.ja  
va:560)  
at org.elasticsearch.search.SearchService.createAndPutContext(SearchServ  
ice.java:532)  
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchServic  
e.java:294)  
at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(S  
earchServiceTransportAction.java:231)  
at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(S  
earchServiceTransportAction.java:228)  
at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(S  
earchServiceTransportAction.java:559)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.  
java:1145)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor  
.java:615)  
at java.lang.Thread.run(Thread.java:745)  
Caused by: org.elasticsearch.ElasticsearchParseException: Failed to derive xcont  
ent from org.elasticsearch.common.bytes.ChannelBufferBytesReference@b668d26f  
at org.elasticsearch.common.xcontent.XContentFactory.xContent(XContentFa  
ctory.java:279)  
at org.elasticsearch.search.SearchService.parseSource(SearchService.java  
:705)  
... 9 more  
[2015-07-29 17:29:48,276][DEBUG][action.search.type] [Black Talon] [blog]  
[0], node[7P3BV3fuTJqRwvvc3Wmcvw], [P], s[STARTED]: Failed to execute [org.elast  
icsearch.action.search.SearchRequest@16ffd379] lastShard [true]  
org.elasticsearch.search.SearchParseException: [blog][0]: from[-1],size[-1]: Par  
se Failure [Failed to parse source [_na_]]  
at org.elasticsearch.search.SearchService.parseSource(SearchService.java  
:735)  
at org.elasticsearch.search.SearchService.createContext(SearchService.ja  
va:560)  
at org.elasticsearch.search.SearchService.createAndPutContext(SearchServ  
ice.java:532)  
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchServic  
e.java:294)  
at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(S  
earchServiceTransportAction.java:231)  
at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(S  
earchServiceTransportAction.java:228)  
at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(S  
earchServiceTransportAction.java:559)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.  
java:1145)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor  
.java:615)  
at java.lang.Thread.run(Thread.java:745)  
Caused by: org.elasticsearch.ElasticsearchParseException: Failed to derive xcont  
ent from org.elasticsearch.common.bytes.ChannelBufferBytesReference@b668d26f  
at org.elasticsearch.common.xcontent.XContentFactory.xContent(XContentFa  
ctory.java:279)  
at org.elasticsearch.search.SearchService.parseSource(SearchService.java  
:705)  
... 9 more  
[2015-07-29 17:29:48,280][DEBUG][action.search.type] [Black Talon] All sh  
ards failed for phase: [query]  
org.elasticsearch.search.SearchParseException: [blog][4]: from[-1],size[-1]: Par  
se Failure [Failed to parse source [_na_]]  
at org.elasticsearch.search.SearchService.parseSource(SearchService.java  
:735)  
at org.elasticsearch.search.SearchService.createContext(SearchService.ja  
va:560)  
at org.elasticsearch.search.SearchService.createAndPutContext(SearchServ  
ice.java:532)  
at org.elasticsearch.search.SearchService.executeQueryPhase(SearchServic  
e.java:294)  
at org.elasticsearch.search.action.SearchServiceTransportAction$5.call(S  
earchServiceTransportAction.java:231)

---

<div class="post-metadata">

**Author:** ![harpreet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harpreet/32/3413_2.png) [@harpreet](https://discuss.elastic.co/u/harpreet)\
**Post date:** [October 29, 2015, 5:19pm UTC](https://discuss.elastic.co/t/searchparseexception-js-client/26532/2 "2015-10-29T17:19:45Z")

</div>

so did you find anything on this. I am having same problem

---

<div class="post-metadata">

**Author:** ![mainec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mainec/32/5557_2.png) [@mainec](https://discuss.elastic.co/u/mainec)\
**Post date:** [October 30, 2015, 8:54am UTC](https://discuss.elastic.co/t/searchparseexception-js-client/26532/3 "2015-10-30T08:54:03Z")

</div>

> [@jbbush](#):
>
> Parse Failure [Failed to parse source [_na_]]

Not knowing a whole lot about what how exactly you are sending the query (or JavaScript in general for that matter): To me this looks like the query doesn't make it to Elasticsearch. Maybe this helps you: [javascript - AJAX Call with Elasticsearch Search - Stack Overflow](http://stackoverflow.com/questions/13144794/ajax-call-with-elasticsearch-search)

---

<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:41pm UTC](https://discuss.elastic.co/t/searchparseexception-js-client/26532/4 "2017-07-05T23:41:45Z")

</div>


