There is no "analyzer" : "not_analyzed", it must be "index" :
"not_analyzed".

http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/mapping-intro.html#_literal_index_literal

Or you can set the analyzer "keyword" in the mapping.

Like this:

https://gist.github.com/jprante/5153404c8f09dc06163f

Jörg

On Wed, Oct 29, 2014 at 10:38 PM, Jarrod C <
[email protected]> wrote:

> Hello, I am trying to run a query that distinguishes between spaces in
> values.  Let's say I have a field called 'color' in my index.  Record 1 has
> "color" : "metallic red" whereas Record 2 has "color": "metallic"
>
> I want to search for 'metallic' but NOT retrieve 'metallic red', and a
> search for 'metallic red' should not return 'red'.
>
> The query below works for 'metallic red' but entering 'red' returns both
> records.  The query also appears to be bypassing Analyzers specified in the
> mappings (such as keyword) as they have no affect.  What should I change it
> to instead?
>
> //Query
> GET /myindex/_search
> {
>    "query": {
>        "match_phrase": {
>           "color": "metallic red"
>        }
>    }
> }
>
> //Data
> { "index" : { "_index" : "myindex", "_type" : "car", "_id" : "1" } }
> { "color" : "metallic red" }
> { "index" : { "_index" : "myindex", "_type" : "car", "_id" : "2" } }
> { "color" : "Metallic RED"}
> { "index" : { "_index" : "myindex", "_type" : "car", "_id" : "3" } }
> { "color" : "rEd" }
>
> //Mapping (no effect for query)
> curl -XPUT 'http://localhost:9200/myindex/' -d '{
>     "settings" : {
>       "analysis": {
>             "analyzer": {
>               "my_analyzer":{
>                         "type": "custom",
>                         "tokenizer" : "keyword",
>                         "lowercase" : true
>                     }
>             }
>     },
>     "mappings" : {
>         "episode" : {
>             "_source" : { "enabled" : false },
>             "properties" : {
>                 "color" : { "type" : "string", "analyzer" : "not_analyzed"
> }
>             }
>         }
>     }
> }
> }'
>
>
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/c18b793b-3288-4935-afb7-28e51fd590c9%40googlegroups.com
> <https://groups.google.com/d/msgid/elasticsearch/c18b793b-3288-4935-afb7-28e51fd590c9%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFdFtesaoe1aONzjLm1nq5PoOtzDc2t77jTAoQ%2BV6OevA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to