Character escaping

We'd had some issues with characters such as "!" causing queries to fail
and as pointed out, we should use the "text" query. However, I've since
noticed that has been deprecated in favor of "match". However, when
changing to a "match" query, it no longer has escaping. Will "match_phrase" accomplish
this?

--

Hi Brandon

On Wed, 2012-11-21 at 04:30 -0800, Brandon Hilkert wrote:

We'd had some issues with characters such as "!" causing queries to
fail and as pointed out, we should use the "text" query. However, I've
since noticed that has been deprecated in favor of "match". However,
when changing to a "match" query, it no longer has escaping. Will
"match_phrase" accomplish this?

'match' is the new name for 'text', as 'match_phrase' is the new name
for 'text_phrase'

what do you mean by "match" no longer has escaping?

(the problem with the query_string/field queries is that they have a
query mini-language, and any syntax error in that language will stop the
query from working at all, eg "!" is the NOT operator, which expects
something to the right of it, but "wow!" would be a syntax error)

--

Concretely, a search for "yahoo!" fails with query_string as expected.
Using "text" queries it works fine. However, switching to "match", it fails
for the same escaping reasons as "query_string". So with "text" being
deprecated, I'm just wondering what the appropriate query is to use to get
the behavior of a "text" query that when querying terms like "yahoo!".

On Wed, Nov 21, 2012 at 7:35 AM, Clinton Gormley clint@traveljury.comwrote:

Hi Brandon

On Wed, 2012-11-21 at 04:30 -0800, Brandon Hilkert wrote:

We'd had some issues with characters such as "!" causing queries to
fail and as pointed out, we should use the "text" query. However, I've
since noticed that has been deprecated in favor of "match". However,
when changing to a "match" query, it no longer has escaping. Will
"match_phrase" accomplish this?

'match' is the new name for 'text', as 'match_phrase' is the new name
for 'text_phrase'

what do you mean by "match" no longer has escaping?

(the problem with the query_string/field queries is that they have a
query mini-language, and any syntax error in that language will stop the
query from working at all, eg "!" is the NOT operator, which expects
something to the right of it, but "wow!" would be a syntax error)

--

--

On Wed, 2012-11-21 at 07:40 -0500, Brandon Hilkert wrote:

Concretely, a search for "yahoo!" fails with query_string as expected.
Using "text" queries it works fine. However, switching to "match", it
fails for the same escaping reasons as "query_string". So with "text"
being deprecated, I'm just wondering what the appropriate query is to
use to get the behavior of a "text" query that when querying terms
like "yahoo!".

No it doesn't. Why do you think it fails? eg:

curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1' -d '
{
"query" : {
"match" : {
"_all" : "yahoo!"
}
}
}
'

[Wed Nov 21 13:45:23 2012] Response:

{

"hits" : {

"hits" : [

{

"_source" : {

"text" : "yahoo is a search engine"

},

"_score" : 0.15342641,

"_index" : "test",

"_id" : "ZLN0QHS-RO-zUw7nM8SK-g",

"_type" : "test"

}

],

"max_score" : 0.15342641,

"total" : 1

},

"timed_out" : false,

"_shards" : {

"failed" : 0,

"successful" : 5,

"total" : 5

},

"took" : 2

}

--

Perhaps it's a version thing? We're on 0.19.4?

Tire::Search::SearchRequestFailed (500 :
{"error":"SearchPhaseExecutionException[Failed to execute phase [query],
total failure; shardFailures
{[SyCzadpDTaGKZl4T3zYA0w][meeteor_development_users][1]:
SearchParseException[[development][1]: from[-1],size[-1]: Parse Failure
[Failed to parse source
[{"query":{"bool":{"should":[{"match":{"_all":{"query":"Apple"}}},....
nested: QueryParsingException[[development] No query registered for
[match]]; }]","status":500}):

We're also using the Ruby gem Tire for the interface.

On Wed, Nov 21, 2012 at 7:46 AM, Clinton Gormley clint@traveljury.comwrote:

On Wed, 2012-11-21 at 07:40 -0500, Brandon Hilkert wrote:

Concretely, a search for "yahoo!" fails with query_string as expected.
Using "text" queries it works fine. However, switching to "match", it
fails for the same escaping reasons as "query_string". So with "text"
being deprecated, I'm just wondering what the appropriate query is to
use to get the behavior of a "text" query that when querying terms
like "yahoo!".

No it doesn't. Why do you think it fails? eg:

curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1' -d '
{
"query" : {
"match" : {
"_all" : "yahoo!"
}
}
}
'

[Wed Nov 21 13:45:23 2012] Response:

{

"hits" : {

"hits" : [

{

"_source" : {

"text" : "yahoo is a search engine"

},

"_score" : 0.15342641,

"_index" : "test",

"_id" : "ZLN0QHS-RO-zUw7nM8SK-g",

"_type" : "test"

}

],

"max_score" : 0.15342641,

"total" : 1

},

"timed_out" : false,

"_shards" : {

"failed" : 0,

"successful" : 5,

"total" : 5

},

"took" : 2

}

--

--

On Wed, 2012-11-21 at 07:52 -0500, Brandon Hilkert wrote:

Perhaps it's a version thing? We're on 0.19.4?

Ah, that's pre "match" query :slight_smile:

You're still using "text"

clint

Tire::Search::SearchRequestFailed (500 :
{"error":"SearchPhaseExecutionException[Failed to execute phase
[query], total failure; shardFailures
{[SyCzadpDTaGKZl4T3zYA0w][meeteor_development_users][1]:
SearchParseException[[development][1]: from[-1],size[-1]: Parse
Failure [Failed to parse source [{"query":{"bool":{"should
":[{"match":{"_all":{"query":"Apple"}}},....

nested: QueryParsingException[[development] No query registered for
[match]]; }]","status":500}):

We're also using the Ruby gem Tire for the interface.

On Wed, Nov 21, 2012 at 7:46 AM, Clinton Gormley
clint@traveljury.com wrote:
On Wed, 2012-11-21 at 07:40 -0500, Brandon Hilkert wrote:
> Concretely, a search for "yahoo!" fails with query_string as
expected.
> Using "text" queries it works fine. However, switching to
"match", it
> fails for the same escaping reasons as "query_string". So
with "text"
> being deprecated, I'm just wondering what the appropriate
query is to
> use to get the behavior of a "text" query that when querying
terms
> like "yahoo!".

    No it doesn't. Why do you think it fails?  eg:
    
    curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1'
     -d '
    {
       "query" : {
          "match" : {
             "_all" : "yahoo!"
          }
       }
    }
    '
    
    # [Wed Nov 21 13:45:23 2012] Response:
    # {
    #    "hits" : {
    #       "hits" : [
    #          {
    #             "_source" : {
    #                "text" : "yahoo is a search engine"
    #             },
    #             "_score" : 0.15342641,
    #             "_index" : "test",
    #             "_id" : "ZLN0QHS-RO-zUw7nM8SK-g",
    #             "_type" : "test"
    #          }
    #       ],
    #       "max_score" : 0.15342641,
    #       "total" : 1
    #    },
    #    "timed_out" : false,
    #    "_shards" : {
    #       "failed" : 0,
    #       "successful" : 5,
    #       "total" : 5
    #    },
    #    "took" : 2
    # }
    
    
    --

--

--

Hahaha ok. Thanks!

On Nov 21, 2012, at 7:54 AM, Clinton Gormley clint@traveljury.com wrote:

On Wed, 2012-11-21 at 07:52 -0500, Brandon Hilkert wrote:

Perhaps it's a version thing? We're on 0.19.4?

Ah, that's pre "match" query :slight_smile:

You're still using "text"

clint

Tire::Search::SearchRequestFailed (500 :
{"error":"SearchPhaseExecutionException[Failed to execute phase
[query], total failure; shardFailures
{[SyCzadpDTaGKZl4T3zYA0w][meeteor_development_users][1]:
SearchParseException[[development][1]: from[-1],size[-1]: Parse
Failure [Failed to parse source [{"query":{"bool":{"should
":[{"match":{"_all":{"query":"Apple"}}},....

nested: QueryParsingException[[development] No query registered for
[match]]; }]","status":500}):

We're also using the Ruby gem Tire for the interface.

On Wed, Nov 21, 2012 at 7:46 AM, Clinton Gormley
clint@traveljury.com wrote:
On Wed, 2012-11-21 at 07:40 -0500, Brandon Hilkert wrote:

Concretely, a search for "yahoo!" fails with query_string as
expected.
Using "text" queries it works fine. However, switching to
"match", it
fails for the same escaping reasons as "query_string". So
with "text"
being deprecated, I'm just wondering what the appropriate
query is to
use to get the behavior of a "text" query that when querying
terms
like "yahoo!".

   No it doesn't. Why do you think it fails?  eg:

   curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1'
    -d '
   {
      "query" : {
         "match" : {
            "_all" : "yahoo!"
         }
      }
   }
   '

   # [Wed Nov 21 13:45:23 2012] Response:
   # {
   #    "hits" : {
   #       "hits" : [
   #          {
   #             "_source" : {
   #                "text" : "yahoo is a search engine"
   #             },
   #             "_score" : 0.15342641,
   #             "_index" : "test",
   #             "_id" : "ZLN0QHS-RO-zUw7nM8SK-g",
   #             "_type" : "test"
   #          }
   #       ],
   #       "max_score" : 0.15342641,
   #       "total" : 1
   #    },
   #    "timed_out" : false,
   #    "_shards" : {
   #       "failed" : 0,
   #       "successful" : 5,
   #       "total" : 5
   #    },
   #    "took" : 2
   # }


   --

--

--

--