When I try to do a query_string type query against the tags field, it
doesn't seem to work. For example, I have a document that contains a
tag "coney island". If I issue this query:
When I try to do a query_string type query against the tags field, it
doesn't seem to work. For example, I have a document that contains a
tag "coney island". If I issue this query:
This is using the "standard" analyzer, which breaks the "coney island" into
terms "coney" and "island". In your doc which uses a "keyword" analyzer, the
term in there is "coney island" itself and not the words. So use the "term"
query like you did below, or explicitly tell the "query_string" which
analyzer you want to use (but I am not certain "keyword" and "query_string"
parse will work well together).
The document is not returned. However, if I switch to "term" query:
{
"term" : {
"tags": "coney island"
}
}
The document is found successfully. Why is this happening?
When I try to do a query_string type query against the tags field, it
doesn't seem to work. For example, I have a document that contains a
tag "coney island". If I issue this query:
This is using the "standard" analyzer, which breaks the "coney island" into
terms "coney" and "island". In your doc which uses a "keyword" analyzer, the
term in there is "coney island" itself and not the words. So use the "term"
query like you did below, or explicitly tell the "query_string" which
analyzer you want to use (but I am not certain "keyword" and "query_string"
parse will work well together).
The document is not returned. However, if I switch to "term" query:
{
"term" : {
"tags": "coney island"
}
}
The document is found successfully. Why is this happening?
I am not sure where you see the "standard" analyzer. I created the
"eulang_tags" custom analyzer as shown above and set the "tags" field
to use it.
The "standard" analyzer should be the default analyzer for "query_string"
unless you change the defaults or explicitly request another analyzer. This
is not tied to the fact you have used a custom analyzer to some of your
fields in a certain type and index.
When I try to do a query_string type query against the tags field, it
doesn't seem to work. For example, I have a document that contains a
tag "coney island". If I issue this query:
This is using the "standard" analyzer, which breaks the "coney island"
into
terms "coney" and "island". In your doc which uses a "keyword" analyzer,
the
term in there is "coney island" itself and not the words. So use the
"term"
query like you did below, or explicitly tell the "query_string" which
analyzer you want to use (but I am not certain "keyword" and
"query_string"
parse will work well together).
The document is not returned. However, if I switch to "term" query:
{
"term" : {
"tags": "coney island"
}
}
The document is found successfully. Why is this happening?
I am not sure where you see the "standard" analyzer. I
created the
"eulang_tags" custom analyzer as shown above and set the
"tags" field
to use it.
The "standard" analyzer should be the default analyzer for
"query_string" unless you change the defaults or explicitly request
another analyzer. This is not tied to the fact you have used a custom
analyzer to some of your fields in a certain type and index.
Actually, the ES docs for mapping mention:
index_analyzer: used when indexing a field
search_analyzer: used when analyzing a field that is part of
a query string
analyzer: sets both index_analyzer and search_analyzer
"query_string": "tags:coney\ island" seemed to work. Though now I'm
not sure whether I should just escape the space this way or other non-
alphanumeric characters as well. Maybe Shay can shed some light on
this.
The query parser breaks down on whitespaces as well. So, the things that gets passed to the analyzer and then construct the query is "coney" and then "island" without doing the actual escaping. Not ideal, but thats how it works...
On Sunday, January 16, 2011 at 12:54 AM, Andrei wrote:
Clint,
"query_string": "tags:coney\ island" seemed to work. Though now I'm
not sure whether I should just escape the space this way or other non-
alphanumeric characters as well. Maybe Shay can shed some light on
this.
All the fields had the "standard" analyzer. I wanted to change it so
that the tags are matched completely, without breaking them up into
words, while maintaining the current behavior with regard to title and
notes. What is the best way of achieving this?
The query parser breaks down on whitespaces as well. So, the things that gets passed to the analyzer and then construct the query is "coney" and then "island" without doing the actual escaping. Not ideal, but thats how it works...
So, do I need to convert this into a dis_max query? Because simply
escaping the whitespace in the query string will not work for title or
notes, because then it forces the words to be a phrase, basically.
All the fields had the "standard" analyzer. I wanted to change it so
that the tags are matched completely, without breaking them up into
words, while maintaining the current behavior with regard to title and
notes. What is the best way of achieving this?
The query parser breaks down on whitespaces as well. So, the things that gets passed to the analyzer and then construct the query is "coney" and then "island" without doing the actual escaping. Not ideal, but thats how it works...
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.