Hi,
I am trying to compare different analyzers to see which ones we should use. But my simple comparison shows me no difference between standard and keyword analyzers.
I wonder what I am missing.
This is the simple test I have.
I have two fields using different analyzer (keyword vs standard):
curl -XPOST localhost:9200/test -d '{
"mappings" : {
"accounts" : {
"properties" : {
"keyword_field" : { type: "string", analyzer : "keyword" },
"standard_field" : { type: "string", analyzer : "standard" }
}
}
}
}'
Then I have two records:
curl -XPUT 'http://localhost:9200/test/accounts/1' -d '{
"keyword_field" : "john doe"
}'
curl -XPUT 'http://localhost:9200/test/accounts/2' -d '{
"standard_field" : "john doe"
}'
Finally, I use this query to get my results:
curl "localhost:9200/test/accounts/_search?pretty=true" -d '{
"query" : {
"query_string" : {
"analyzer" : "keyword", //also tried "standard"
"query" : "john doe" // also tried "john" or "doe"
}
}
}'
In the query_string above, I have tried both keyword and standard.
However, they always return me both documents with same score no matter which analyzer I have in my query_string.
I also tried replacing the query "john doe" with either only "john" or "doe", and it still returns me both documents regardless the analyzer in my query_string.
My understanding is that keyword analyzer does not tokenize while standard analyzer does. So I'd expect different search results.
If this is not a correct test to see the difference between the two, what test can I use to see some differences so I know which one to use in my app?
Thanks.