# Parentheses in http querystring help needed

**URL:** <https://discuss.elastic.co/t/parentheses-in-http-querystring-help-needed/12969>\
**Category:** Elasticsearch\
**Created:** [July 27, 2013, 7:16pm UTC](https://discuss.elastic.co/t/parentheses-in-http-querystring-help-needed/12969 "2013-07-27T19:16:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diederik\_Meijer\_Ten\_](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@Diederik\_Meijer\_Ten\_](https://discuss.elastic.co/u/Diederik_Meijer_Ten_)\
**Post date:** [July 27, 2013, 7:16pm UTC](https://discuss.elastic.co/t/parentheses-in-http-querystring-help-needed/12969/1 "2013-07-27T19:16:58Z")

</div>

Dear list,

We are running EC on top of a Mongo DB and it works great. An iPhone client  
queries EC through http calls.

I would like to be able to have the search term include parentheses and a  
colon, I have tried to escape and encode the parentheses as per the Lucene  
docs (see sample query string below), but it does not seem to work  
properly, is there anybody out there who knows how to do this?

?q=rechtsgebied\_rechtspraak:%22Belasting%22+%22%5C%28hierna%5C:%20de%20Wet%5C%29%22&default\_operator=AND&sort=datum\_gepubliceerd\_ymd:desc&size=20&from=0

This part is what this request is  
about: %22%5C%28hierna%5C:%20de%20Wet%5C%29%22

Unencoded it reads: (hierna: de Wet)

Many thanks,

Diederik

--  
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:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [July 30, 2013, 3:57pm UTC](https://discuss.elastic.co/t/parentheses-in-http-querystring-help-needed/12969/2 "2013-07-30T15:57:52Z")

</div>

Hello Diederik,

It depends on what's the  
analyzer[http://www.elasticsearch.org/guide/reference/index-modules/analysis/](http://www.elasticsearch.org/guide/reference/index-modules/analysis/)you're  
using for both indexing and searching. For example, if on indexing  
you have not\_analyzed and you have a string with parentheses, the generated  
token will include everything, even the parentheses. But when you search,  
the default query  
string[http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query/](http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query/)uses  
the standard  
analyzer[http://www.elasticsearch.org/guide/reference/index-modules/analysis/standard-analyzer/](http://www.elasticsearch.org/guide/reference/index-modules/analysis/standard-analyzer/).  
Which will take out your parentheses as if you didn't specify them.

You can use the analyze  
API[http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze/](http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze/)to  
check how various analyzers break down your text. For example, the  
standard analyzer escapes parentheses:

# curl -XGET 'localhost:9200/\_analyze?analyzer=standard&pretty' -d '(test)'

{  
"tokens" : [ {  
"token" : "test",  
"start\_offset" : 1,  
"end\_offset" : 5,  
"type" : "",  
"position" : 1  
} ]  
}

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Sat, Jul 27, 2013 at 10:16 PM, [diederik@tenhorses.com](mailto:diederik@tenhorses.com) wrote:

> Dear list,
> 
> We are running EC on top of a Mongo DB and it works great. An iPhone  
> client queries EC through http calls.
> 
> I would like to be able to have the search term include parentheses and a  
> colon, I have tried to escape and encode the parentheses as per the Lucene  
> docs (see sample query string below), but it does not seem to work  
> properly, is there anybody out there who knows how to do this?
> 
> ?q=rechtsgebied\_rechtspraak:%22Belasting%22+%22%5C%28hierna%5C:%20de%20Wet%5C%29%22&default\_operator=AND&sort=datum\_gepubliceerd\_ymd:desc&size=20&from=0
> 
> This part is what this request is  
> about: %22%5C%28hierna%5C:%20de%20Wet%5C%29%22
> 
> Unencoded it reads: (hierna: de Wet)
> 
> Many thanks,
> 
> Diederik
> 
> --  
> 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).

--  
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:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [July 30, 2013, 6:49pm UTC](https://discuss.elastic.co/t/parentheses-in-http-querystring-help-needed/12969/3 "2013-07-30T18:49:31Z")

</div>

Here is an example query with the query\_string. Note that the parenthesis  
are there, but they act as if they aren't (because they aren't needed but  
are still logically correct):

{  
"from" : 0,  
"size" : 20,  
"query" : {  
"bool" : {  
"must" : {  
"query\_string" : {  
"query" : "_(gn: curly)_"  
}  
}  
}  
},  
"version" : true,  
"explain" : false,  
"fields" : ["\_ttl", "\_source"]  
}

And here is the JSON source from the response:

{ "telno" : "7214560001" , "cnam" : "THREE STOOGES" , "gn" : "Larry, Curly,  
and Moe" , "o" : "Columbia Pictures" , "addr" : "Grover St" , "city" :  
"Hollywood" , "state" : "CA" }

On Saturday, July 27, 2013 3:16:58 PM UTC-4, [died...@tenhorses.com](mailto:died...@tenhorses.com) wrote:

> Dear list,
> 
> We are running EC on top of a Mongo DB and it works great. An iPhone  
> client queries EC through http calls.
> 
> I would like to be able to have the search term include parentheses and a  
> colon, I have tried to escape and encode the parentheses as per the Lucene  
> docs (see sample query string below), but it does not seem to work  
> properly, is there anybody out there who knows how to do this?
> 
> ?q=rechtsgebied\_rechtspraak:%22Belasting%22+%22%5C%28hierna%5C:%20de%20Wet%5C%29%22&default\_operator=AND&sort=datum\_gepubliceerd\_ymd:desc&size=20&from=0
> 
> This part is what this request is  
> about: %22%5C%28hierna%5C:%20de%20Wet%5C%29%22
> 
> Unencoded it reads: (hierna: de Wet)
> 
> Many thanks,
> 
> Diederik

--  
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:** ![Diederik\_Meijer\_Ten\_](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@Diederik\_Meijer\_Ten\_](https://discuss.elastic.co/u/Diederik_Meijer_Ten_)\
**Post date:** [July 30, 2013, 8:38pm UTC](https://discuss.elastic.co/t/parentheses-in-http-querystring-help-needed/12969/4 "2013-07-30T20:38:59Z")

</div>

Thank you Radu, will look into this tomorrow,

Diederik

Verstuurd vanaf mijn iPhone

Op 30 jul. 2013 om 17:57 heeft Radu Gheorghe [radu.gheorghe@sematext.com](mailto:radu.gheorghe@sematext.com) het volgende geschreven:

> Hello Diederik,
> 
> It depends on what's the analyzer you're using for both indexing and searching. For example, if on indexing you have not\_analyzed and you have a string with parentheses, the generated token will include everything, even the parentheses. But when you search, the default query string uses the standard analyzer. Which will take out your parentheses as if you didn't specify them.
> 
> You can use the analyze API to check how various analyzers break down your text. For example, the standard analyzer escapes parentheses:
> 
> # curl -XGET 'localhost:9200/\_analyze?analyzer=standard&pretty' -d '(test)'
> 
> {  
> "tokens" : [ {  
> "token" : "test",  
> "start\_offset" : 1,  
> "end\_offset" : 5,  
> "type" : "",  
> "position" : 1  
> } ]  
> }
> 
> ## Best regards, Radu
> 
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> 
> On Sat, Jul 27, 2013 at 10:16 PM, [diederik@tenhorses.com](mailto:diederik@tenhorses.com) wrote:
> 
> > Dear list,
> > 
> > We are running EC on top of a Mongo DB and it works great. An iPhone client queries EC through http calls.
> > 
> > I would like to be able to have the search term include parentheses and a colon, I have tried to escape and encode the parentheses as per the Lucene docs (see sample query string below), but it does not seem to work properly, is there anybody out there who knows how to do this?
> > 
> > ?q=rechtsgebied\_rechtspraak:%22Belasting%22+%22%5C%28hierna%5C:%20de%20Wet%5C%29%22&default\_operator=AND&sort=datum\_gepubliceerd\_ymd:desc&size=20&from=0
> > 
> > This part is what this request is about: %22%5C%28hierna%5C:%20de%20Wet%5C%29%22
> > 
> > Unencoded it reads: (hierna: de Wet)
> > 
> > Many thanks,
> > 
> > ## Diederik
> > 
> > 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).
> 
> --  
> You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/nVuj\_7jImJ8/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nVuj_7jImJ8/unsubscribe).  
> To unsubscribe from this group and all its topics, 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).

--  
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:** ![Diederik\_Meijer\_Ten\_](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@Diederik\_Meijer\_Ten\_](https://discuss.elastic.co/u/Diederik_Meijer_Ten_)\
**Post date:** [July 30, 2013, 8:39pm UTC](https://discuss.elastic.co/t/parentheses-in-http-querystring-help-needed/12969/5 "2013-07-30T20:39:34Z")

</div>

Thank you, will look into this tomorrow,

Diederik

Verstuurd vanaf mijn iPhone

Op 30 jul. 2013 om 20:49 heeft InquiringMind [brian.from.fl@gmail.com](mailto:brian.from.fl@gmail.com) het volgende geschreven:

> Here is an example query with the query\_string. Note that the parenthesis are there, but they act as if they aren't (because they aren't needed but are still logically correct):
> 
> {  
> "from" : 0,  
> "size" : 20,  
> "query" : {  
> "bool" : {  
> "must" : {  
> "query\_string" : {  
> "query" : "(gn: curly)"  
> }  
> }  
> }  
> },  
> "version" : true,  
> "explain" : false,  
> "fields" : ["\_ttl", "\_source"]  
> }
> 
> And here is the JSON source from the response:
> 
> { "telno" : "7214560001" , "cnam" : "THREE STOOGES" , "gn" : "Larry, Curly, and Moe" , "o" : "Columbia Pictures" , "addr" : "Grover St" , "city" : "Hollywood" , "state" : "CA" }
> 
> On Saturday, July 27, 2013 3:16:58 PM UTC-4, [died...@tenhorses.com](mailto:died...@tenhorses.com) wrote:
> 
> > Dear list,
> > 
> > We are running EC on top of a Mongo DB and it works great. An iPhone client queries EC through http calls.
> > 
> > I would like to be able to have the search term include parentheses and a colon, I have tried to escape and encode the parentheses as per the Lucene docs (see sample query string below), but it does not seem to work properly, is there anybody out there who knows how to do this?
> > 
> > ?q=rechtsgebied\_rechtspraak:%22Belasting%22+%22%5C%28hierna%5C:%20de%20Wet%5C%29%22&default\_operator=AND&sort=datum\_gepubliceerd\_ymd:desc&size=20&from=0
> > 
> > This part is what this request is about: %22%5C%28hierna%5C:%20de%20Wet%5C%29%22
> > 
> > Unencoded it reads: (hierna: de Wet)
> > 
> > Many thanks,
> > 
> > Diederik
> 
> --  
> You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/nVuj\_7jImJ8/unsubscribe](https://groups.google.com/d/topic/elasticsearch/nVuj_7jImJ8/unsubscribe).  
> To unsubscribe from this group and all its topics, 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).

--  
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:23am UTC](https://discuss.elastic.co/t/parentheses-in-http-querystring-help-needed/12969/6 "2017-07-06T02:23:40Z")

</div>


