# Getting SearchPhraseException

**URL:** <https://discuss.elastic.co/t/getting-searchphraseexception/13975>\
**Category:** Elasticsearch\
**Created:** [October 16, 2013, 6:29pm UTC](https://discuss.elastic.co/t/getting-searchphraseexception/13975 "2013-10-16T18:29:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinod\_eligeti](https://avatars.discourse-cdn.com/v4/letter/v/c4cdca/32.png) [@vinod\_eligeti](https://discuss.elastic.co/u/vinod_eligeti)\
**Post date:** [October 16, 2013, 6:29pm UTC](https://discuss.elastic.co/t/getting-searchphraseexception/13975/1 "2013-10-16T18:29:44Z")

</div>

I am getting the following exception:

org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
execute phase [query], total failure; shardFailures  
{[0tdGifEsSHu06F1nr0RnKg][logstore:1:1381881600000][1]:  
RemoteTransportException[[Ani-Mator][inet[/10.129.35.115:9300]][search/phase/query]];  
nested: SearchParseException[[logstore:1:1381881600000][1]:  
from[-1],size[100]: Parse Failure [Failed to parse source  
[{"size":100,"query\_binary":"ZXhjZXB0aW9u","filter":{"range":{"timestamp":{"from":1381946862387,"to":1381947762387,"include\_lower":true,"include\_upper":true}}},"sort":[{"timestamp":{"order":"asc"}}]}]]];  
nested: ElasticSearchParseException[Failed to derive xcontent from  
(offset=0, length=9): [101, 120, 99, 101, 112, 116, 105, 111, 110]];  
}{[sn4WUR-RToKK6XnNlARwCg][logstore:1:1381881600000][4]:  
RemoteTransportException[[Cecilia  
Reyes][inet[/10.129.34.115:9300]][search/phase/query]]; nested:  
SearchParseException[[logstore:1:1381881600000][4]: from[-1],size[100]:  
Parse Failure [Failed to parse source  
[{"size":100,"query\_binary":"ZXhjZXB0aW9u","filter":{"range":{"timestamp":{"from":1381946862387,"to":1381947762387,"include\_lower":true,"include\_upper":true}}},"sort":[{"timestamp":{"order":"asc"}}]}]]];  
nested: ElasticSearchParseException[Failed to derive xcontent from  
(offset=0, length=9): [101, 120, 99, 101, 112, 116, 105, 111, 110]];  
}{[iCScEUaJTOKQtiOhrUcSDw][logstore:1:1381881600000][2]:  
RemoteTransportException[[Creel, Carl  
"Crusher"][inet[/10.129.38.115:9300]][search/phase/query]]; nested:  
SearchParseException[[logstore:1:1381881600000][2]: from[-1],size[100]:  
Parse Failure [Failed to parse source  
[{"size":100,"query\_binary":"ZXhjZXB0aW9u","filter":{"range":{"timestamp":{"from":1381946862387,"to":1381947762387,"include\_lower":true,"include\_upper":true}}},"sort":[{"timestamp":{"order":"asc"}}]}]]];  
nested: ElasticSearchParseException[Failed to derive xcontent from  
(offset=0, length=9): [101, 120, 99, 101, 112, 116, 105, 111, 110]];  
}{[T1bVeKJrQUWVfjCbu483dQ][logstore:1:1381881600000][3]:  
RemoteTransportException[[Portal][inet[/10.129.36.115:9300]][search/phase/query]];  
nested: SearchParseException[[logstore:1:1381881600000][3]:  
from[-1],size[100]: Parse Failure [Failed to parse source  
[{"size":100,"query\_binary":"ZXhjZXB0aW9u","filter":{"range":{"timestamp":{"from":1381946862387,"to":1381947762387,"include\_lower":true,"include\_upper":true}}},"sort":[{"timestamp":{"order":"asc"}}]}]]];  
nested: ElasticSearchParseException[Failed to derive xcontent from  
(offset=0, length=9): [101, 120, 99, 101, 112, 116, 105, 111, 110]];  
}{[iCScEUaJTOKQtiOhrUcSDw][logstore:1:1381881600000][0]:  
RemoteTransportException[[Creel, Carl  
"Crusher"][inet[/10.129.38.115:9300]][search/phase/query]]; nested:  
SearchParseException[[logstore:1:1381881600000][0]: from[-1],size[100]:  
Parse Failure [Failed to parse source  
[{"size":100,"query\_binary":"ZXhjZXB0aW9u","filter":{"range":{"timestamp":{"from":1381946862387,"to":1381947762387,"include\_lower":true,"include\_upper":true}}},"sort":[{"timestamp":{"order":"asc"}}]}]]];  
nested: ElasticSearchParseException[Failed to derive xcontent from  
(offset=0, length=9): [101, 120, 99, 101, 112, 116, 105, 111, 110]]; }

My code looks like:

rangeFilter =  
FilterBuilders.rangeFilter(LogMessageHelper.TIMESTAMP).from(start).to(end);

sb = sc.prepareSearch(logIndex.toString())  
.setTypes(LogStorageModule.LOGS\_DOC\_TYPE)  
.setQuery(qb).setSize(logsPerPage - logs.size())  
.addSort(LogMessageHelper.TIMESTAMP, SortOrder.ASC)  
.setFilter(rangeFilter);

where qb is initialized as:

BytesArray qb = new BytesArray(query);

the query string is passed from the user and is like

_{"term":{"message":"exception"}}_

what am i doing wrong?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [October 17, 2013, 1:25pm UTC](https://discuss.elastic.co/t/getting-searchphraseexception/13975/2 "2013-10-17T13:25:46Z")

</div>

I don't see anything terribly wrong here. What I would is trying the build  
the query too using QueryBuilders and get from the users only field name  
and query, but maybe that's not possible in your case.  
I think you get back an error when the query that is being passed in as a  
parameter is not valid json? Can you check that?

On Wednesday, October 16, 2013 8:29:44 PM UTC+2, vinod eligeti wrote:

> I am getting the following exception:
> 
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
> execute phase [query], total failure; shardFailures  
> {[0tdGifEsSHu06F1nr0RnKg][logstore:1:1381881600000][1]:  
> RemoteTransportException[[Ani-Mator][inet[/10.129.35.115:9300]][search/phase/query]];  
> nested: SearchParseException[[logstore:1:1381881600000][1]:  
> from[-1],size[100]: Parse Failure [Failed to parse source  
> [{"size":100,"query\_binary":"ZXhjZXB0aW9u","filter":{"range":{"timestamp":{"from":1381946862387,"to":1381947762387,"include\_lower":true,"include\_upper":true}}},"sort":[{"timestamp":{"order":"asc"}}]}]]];  
> nested: ElasticSearchParseException[Failed to derive xcontent from  
> (offset=0, length=9): [101, 120, 99, 101, 112, 116, 105, 111, 110]];  
> }{[sn4WUR-RToKK6XnNlARwCg][logstore:1:1381881600000][4]:  
> RemoteTransportException[[Cecilia  
> Reyes][inet[/10.129.34.115:9300]][search/phase/query]]; nested:  
> SearchParseException[[logstore:1:1381881600000][4]: from[-1],size[100]:  
> Parse Failure [Failed to parse source  
> [{"size":100,"query\_binary":"ZXhjZXB0aW9u","filter":{"range":{"timestamp":{"from":1381946862387,"to":1381947762387,"include\_lower":true,"include\_upper":true}}},"sort":[{"timestamp":{"order":"asc"}}]}]]];  
> nested: ElasticSearchParseException[Failed to derive xcontent from  
> (offset=0, length=9): [101, 120, 99, 101, 112, 116, 105, 111, 110]];  
> }{[iCScEUaJTOKQtiOhrUcSDw][logstore:1:1381881600000][2]:  
> RemoteTransportException[[Creel, Carl  
> "Crusher"][inet[/10.129.38.115:9300]][search/phase/query]]; nested:  
> SearchParseException[[logstore:1:1381881600000][2]: from[-1],size[100]:  
> Parse Failure [Failed to parse source  
> [{"size":100,"query\_binary":"ZXhjZXB0aW9u","filter":{"range":{"timestamp":{"from":1381946862387,"to":1381947762387,"include\_lower":true,"include\_upper":true}}},"sort":[{"timestamp":{"order":"asc"}}]}]]];  
> nested: ElasticSearchParseException[Failed to derive xcontent from  
> (offset=0, length=9): [101, 120, 99, 101, 112, 116, 105, 111, 110]];  
> }{[T1bVeKJrQUWVfjCbu483dQ][logstore:1:1381881600000][3]:  
> RemoteTransportException[[Portal][inet[/10.129.36.115:9300]][search/phase/query]];  
> nested: SearchParseException[[logstore:1:1381881600000][3]:  
> from[-1],size[100]: Parse Failure [Failed to parse source  
> [{"size":100,"query\_binary":"ZXhjZXB0aW9u","filter":{"range":{"timestamp":{"from":1381946862387,"to":1381947762387,"include\_lower":true,"include\_upper":true}}},"sort":[{"timestamp":{"order":"asc"}}]}]]];  
> nested: ElasticSearchParseException[Failed to derive xcontent from  
> (offset=0, length=9): [101, 120, 99, 101, 112, 116, 105, 111, 110]];  
> }{[iCScEUaJTOKQtiOhrUcSDw][logstore:1:1381881600000][0]:  
> RemoteTransportException[[Creel, Carl  
> "Crusher"][inet[/10.129.38.115:9300]][search/phase/query]]; nested:  
> SearchParseException[[logstore:1:1381881600000][0]: from[-1],size[100]:  
> Parse Failure [Failed to parse source  
> [{"size":100,"query\_binary":"ZXhjZXB0aW9u","filter":{"range":{"timestamp":{"from":1381946862387,"to":1381947762387,"include\_lower":true,"include\_upper":true}}},"sort":[{"timestamp":{"order":"asc"}}]}]]];  
> nested: ElasticSearchParseException[Failed to derive xcontent from  
> (offset=0, length=9): [101, 120, 99, 101, 112, 116, 105, 111, 110]]; }
> 
> My code looks like:
> 
> rangeFilter =  
> FilterBuilders.rangeFilter(LogMessageHelper.TIMESTAMP).from(start).to(end);
> 
> sb = sc.prepareSearch(logIndex.toString())  
> .setTypes(LogStorageModule.LOGS\_DOC\_TYPE)  
> .setQuery(qb).setSize(logsPerPage - logs.size())  
> .addSort(LogMessageHelper.TIMESTAMP, SortOrder.ASC)  
> .setFilter(rangeFilter);
> 
> where qb is initialized as:
> 
> BytesArray qb = new BytesArray(query);
> 
> the query string is passed from the user and is like
> 
> _{"term":{"message":"exception"}}_
> 
> what am i doing wrong?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:11am UTC](https://discuss.elastic.co/t/getting-searchphraseexception/13975/3 "2017-07-06T02:11:55Z")

</div>


