Synonym analyzer not picked up as search_analyzer for field

I'm using ES 1.0.0. I'm storing products with a "color" string field which
is just a single string representing a color (e.g. "white" or "purple"). I
want queries for variations of these color names to return results, so I've
defined the following analyzer and set it to be used as the search_analyzer
for the color field:

Settings

{
"analysis": {
"analyzer": {

             "color_synonyms" : {

                      "tokenizer" : "whitespace",

                       "filter" : ["synonyms"]

           }

         },

        "filter" : {

              "synonyms" : {

                    "type" : "synonym",

                       "synonyms_path" : "analysis/synonyms.txt",

                        "ignore_case" : true

              }

         }

 }

}

Mapping:
"color" : {

       "type" : "string",

       "index_analyzer" : "keyword",

       "search_analyzer" : "color_synonyms"

     },

I've tested that the analyzer works correctly:

curl -XGET 'localhost:9200/products/_analyze?analyzer=color_synonyms' -d
'purple'

{"tokens":[{"token":"lila","start_offset":0,"end_offset":6,"type":"SYNONYM"
,"position":1},{"token":"purpur","start_offset":0,"end_offset":6,"type":
"SYNONYM","position":1},{"token":"purple","start_offset":0,"end_offset":6,
"type":"SYNONYM","position":1}]}

But it seems it doesn't use the analyzer for the color field:

curl -XGET 'localhost:9200/products/_analyze?field=Product.color' -d
'purple'

{"tokens":[{"token":"purple","start_offset":0,"end_offset":6,"type":"word"
,"position":1}]}

Am I missing something obvious or doing something wrong?

--
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/fa5b8282-019b-434a-94b4-3a60eec7d893%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

The index analyzer is used when the field is specific in the analyze
request.

https://github.com/elasticsearch/elasticsearch/blob/1.x/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java#L130

--
Ivan

On Fri, Apr 25, 2014 at 1:43 AM, Andreas Wikell <andreas.wikell@schibsted.se

wrote:

I'm using ES 1.0.0. I'm storing products with a "color" string field which
is just a single string representing a color (e.g. "white" or "purple"). I
want queries for variations of these color names to return results, so I've
defined the following analyzer and set it to be used as the search_analyzer
for the color field:

Settings

{
"analysis": {
"analyzer": {

             "color_synonyms" : {

                      "tokenizer" : "whitespace",

                       "filter" : ["synonyms"]

           }

         },

        "filter" : {

              "synonyms" : {

                    "type" : "synonym",

                       "synonyms_path" : "analysis/synonyms.txt",

                        "ignore_case" : true

              }

         }

 }

}

Mapping:
"color" : {

       "type" : "string",

       "index_analyzer" : "keyword",

       "search_analyzer" : "color_synonyms"

     },

I've tested that the analyzer works correctly:

curl -XGET 'localhost:9200/products/_analyze?analyzer=color_synonyms' -d
'purple'

{"tokens":[{"token":"lila","start_offset":0,"end_offset":6,"type":
"SYNONYM","position":1},{"token":"purpur","start_offset":0,"end_offset":6,
"type":"SYNONYM","position":1},{"token":"purple","start_offset":0,
"end_offset":6,"type":"SYNONYM","position":1}]}

But it seems it doesn't use the analyzer for the color field:

curl -XGET 'localhost:9200/products/_analyze?field=Product.color' -d
'purple'

{"tokens":[{"token":"purple","start_offset":0,"end_offset":6,"type":
"word","position":1}]}

Am I missing something obvious or doing something wrong?

--
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/fa5b8282-019b-434a-94b4-3a60eec7d893%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/fa5b8282-019b-434a-94b4-3a60eec7d893%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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/CALY%3DcQA-1ddp6N_N9CT37vCejH4qdOSkGr%3DYkkym-Q5JBd8EXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.