How to validate field value to search?

Hello everybody.
Example i have a search query:
{"query":{"bool":{"must":[],"must_not":[],"should":[{"query_string":{"default_field":"tweet.user","query":"
kompa)"}}]}},"from":0,"size":50,"sort":[],"facets":{}}, when i run this
query on elasticsearch server i will got ParseException:

Caused by: org.apache.lucene.queryparser.classic.ParseException: Cannot
parse '(
kompa': Encountered "" at line 1, column 6.
Was expecting one of:
...
...
...
"+" ...
"-" ...
...
"(" ...
")" ...
"*" ...
"^" ...
...
...
<FUZZY_SLOP> ...
...
...
...
"[" ...
"{" ...
...

    at 

org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryPars
erBase.java:126)

========================

But if this query:
{"query":{"bool":{"must":[],"must_not":[],"should":[{"query_string":{"default_field":"tweet.user","query":"
(kompa)"}}]}},"from":0,"size":50,"sort":[],"facets":{}},
this can do search well.

So i want to check field value before executing a search.

  • I don't know what rule that elasticsearch used to check the field value.
    I try on the elasticsearc.org but couldn't found any thing.
    Because there are many case with many special characters to validate,
    example: {}$%^&
    ()@!`

Does anyone have some idea ? Thanks;

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

IMO this is just how the lucene query parser works, you need to escape
those things.
do you need to have support for query syntax at all like boolean operators?
if not maybe match query
(Elasticsearch Platform — Find real-time answers at scale | Elastic) can
help you

simon

On Wednesday, August 28, 2013 7:59:33 PM UTC+2, Duy Binh wrote:

Hello everybody.
Example i have a search query:
{"query":{"bool":{"must":,"must_not":,"should":[{"query_string":{"default_field":"tweet.user","query":"
kompa)"}}]}},"from":0,"size":50,"sort":,"facets":{}}, when i run this
query on elasticsearch server i will got ParseException:

Caused by: org.apache.lucene.queryparser.classic.ParseException: Cannot
parse '(
kompa': Encountered "" at line 1, column 6.
Was expecting one of:
...
...
...
"+" ...
"-" ...
...
"(" ...
")" ...
"*" ...
"^" ...
...
...
<FUZZY_SLOP> ...
...
...
...
"[" ...
"{" ...
...

    at 

org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryPars
erBase.java:126)

========================

But if this query:
{"query":{"bool":{"must":,"must_not":,"should":[{"query_string":{"default_field":"tweet.user","query":"
(kompa)"}}]}},"from":0,"size":50,"sort":,"facets":{}},
this can do search well.

So i want to check field value before executing a search.

  • I don't know what rule that elasticsearch used to check the field
    value. I try on the elasticsearc.org but couldn't found any thing.
    Because there are many case with many special characters to validate,
    example: {}$%^&
    ()@!`

Does anyone have some idea ? Thanks;

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks simmonw;
I got that elasticsearch uses Java Lucene to parse and validation the query.

But with the query:
{"query":{"bool":{"must":,"must_not":,"should":[{"query_string":{"default_field":"tweet.user","query":"
(kompa)"}}]}},"from":0,"size":50,"sort":,"facets":{}}
it works; so i think no need to escape it. Do you think so ?

On Thu, Aug 29, 2013 at 3:34 AM, simonw
simon.willnauer@elasticsearch.comwrote:

IMO this is just how the lucene query parser works, you need to escape
those things.
do you need to have support for query syntax at all like boolean
operators? if not maybe match query (
Elasticsearch Platform — Find real-time answers at scale | Elastic) can
help you

simon

On Wednesday, August 28, 2013 7:59:33 PM UTC+2, Duy Binh wrote:

Hello everybody.
Example i have a search query: {"query":{"bool":{"must":,"**
must_not":,"should":[{"query_string":{"default_field"
:"tweet.user","query":"kompa)"**}}]}},"from":0,"size":50,"sort":[],"facets":{}},
when i run this query on elasticsearch server i will got ParseException:
------------------------------
-------------------------
Caused by: org.apache.lucene.queryparser.**classic.ParseException:
Cannot parse '(
kompa': Encountered "" at line 1, column 6.
Was expecting one of:
...
...
...
"+" ...
"-" ...
...
"(" ...
")" ...
"*" ...
"^" ...
...
...
<FUZZY_SLOP> ...
...
...
...
"[" ...
"{" ...
...

    at org.apache.lucene.queryparser.**classic.QueryParserBase.parse(

**QueryPars
erBase.java:126)

========================

But if this query: {"query":{"bool":{"must":,"**
must_not":,"should":[{"query_string":{"default_field"
:"tweet.user","query":"(kompa)"}}]}},"from":0,"size":50,"
sort":,"facets":{}},
this can do search well.

So i want to check field value before executing a search.

  • I don't know what rule that elasticsearch used to check the field
    value. I try on the elasticsearc.org but couldn't found any thing.
    Because there are many case with many special characters to validate,
    example: {}$%^&
    ()@!`

Does anyone have some idea ? Thanks;

--
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/Sys8ClJ_-EU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.