Query_string query, forward slash, how to explained?

Hi, all

Assume I have the document:

{

                "id": "/Users/jason/Documents/nose/DS_Store",
                "name": "danny",
                "language": "",
                "created": "2014-03-26T14:40:17Z",

}

And I want to use query_string query to find the "id" field with the exact
value "/Users/jason/Documents/nose/DS_Store"

The following command cannot find the above document:

{ "query":

  { "query_string":  
      {  "query": "id:\\/Users\\/jason\\/Documents\\/nose\\/DS_Store"}
  }

}

The index_analyzer of "id" field include the tokenizer "path_hierarchy"
and no filter. The search_analyzer of it is standard.

Are there any possible reason of it ??

BTW, I can use term query to find the document by using:

{ "query":
{ "term":
{ "id": "/Users/jason/Documents/nose/DS_Store"}
}
}

So I think there might exist something in the query_string query.

And are there any ways to know what operations does a query_string query
rewrite into?

Ideas?

Ivan

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/85f49c48-f2a7-4b32-8e01-e01b59bb0624%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

The term query is really what you want, but if you need the query_string
query, you can always override the search analyzer at query time:

{
"query": {
"query_string": {
"query": "id:\/Users\/jason\/Documents\/nose\/DS_Store",
"analyzer": "<your_index_analyzer_name>"
}
}
}

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c7ec1d09-82d1-4328-8c0d-a72a445c1c15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Binh,

The search analyzer is assigned in the schema. So in theory, it can find
the document, right?

So do you mean the search analyzer cannot be applied automatically in this
case ? But I had make sure some other case will do apply the search
analyzer.

cheers,

Ivan

Binh Ly於 2014年3月27日星期四UTC+8下午9時34分39秒寫道:

The term query is really what you want, but if you need the query_string
query, you can always override the search analyzer at query time:

{
"query": {
"query_string": {
"query": "id:\/Users\/jason\/Documents\/nose\/DS_Store",
"analyzer": "<your_index_analyzer_name>"
}
}
}

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/047a9c18-f166-4268-9af8-e3642bc0c598%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Since your search_analyzer is standard, it will tokenize your query string
as standard (i.e. it will break it down), then it will match it against the
path_hierarchy tokens in the index which will not match. Since you indexed
as path_hierarchy and you want to search using an exact match, then you can
either use terms, or use the same exact analyzer (path_hierarchy) at query
time.

You can always do a bool query with the term part in 1 clause, and the
query_string part in another clause if that's what you need.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/016bf83e-7e2c-4900-9aa1-965b187b8060%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi, Binh

I got it.

I did not notice the standard analyzer will also split "/". Thanks a lot.

Binh Ly於 2014年3月27日星期四UTC+8下午11時24分34秒寫道:

Since your search_analyzer is standard, it will tokenize your query string
as standard (i.e. it will break it down), then it will match it against the
path_hierarchy tokens in the index which will not match. Since you indexed
as path_hierarchy and you want to search using an exact match, then you can
either use terms, or use the same exact analyzer (path_hierarchy) at query
time.

You can always do a bool query with the term part in 1 clause, and the
query_string part in another clause if that's what you need.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2b24274f-2cf6-4c47-876f-6d8c73542833%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.