Created
January 23, 2012 13:22
-
-
Save frazerh/1663100 to your computer and use it in GitHub Desktop.
Not analyzed field and its role in the _all field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE 'http://localhost:9200/blog/' | |
curl -XPUT 'http://localhost:9200/blog/' | |
curl -XPUT 'http://localhost:9200/blog/doc/_mapping' -d ' | |
{ | |
"doc" : { | |
"dynamic" : false, | |
"properties" : { | |
"title" : { "type" : "string"}, | |
"summary" : { "type" : "string" }, | |
"tags" : { type: "string", "index" : "not_analyzed" }, | |
"user_id" : { type: "long" } | |
} | |
} | |
}' | |
curl -X POST "http://localhost:9200/blog/doc" -d '{ "title" : "some title 1", "summary" : "some summary 1", "tags" : "@@more-help", "user_id" : 1 }' | |
curl -X POST "http://localhost:9200/blog/doc" -d '{ "title" : "some title 2", "summary" : "some summary 2", "tags" : "@@more-sugar", "user_id" : 2 }' | |
curl -X POST "http://localhost:9200/blog/doc" -d '{ "title" : "some title 3", "summary" : "some summary 3", "tags" : "@@more-info", "user_id" : 11 }' | |
# tags field that is not_analyzed does not seem to have its content in the _all field | |
curl -X GET "http://localhost:9200/blog/_search?pretty=true" -d '{ "query": { "query_string": { "query": "@@more-help*" } } }' | |
{ | |
"took" : 5, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 0, | |
"max_score" : null, | |
"hits" : [ ] | |
} | |
} | |
# can be queried by specifying the field | |
curl -X GET "http://localhost:9200/blog/_search?pretty=true" -d '{ "query": { "query_string": { "query": "tags:@@more-help*" } } }' | |
{ | |
"took" : 1, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 1, | |
"max_score" : 1.0, | |
"hits" : [ { | |
"_index" : "blog", | |
"_type" : "doc", | |
"_id" : "WDa3gL8yRxGk8GGrQm2WBA", | |
"_score" : 1.0, "_source" : { "title" : "some title 1", "summary" : "some summary 1", "tags" : "@@more-help", "user_id" : 1 } | |
} ] | |
} | |
} | |
# tags field looks like it was analyzed for the _all field even though its set to not_analyzed | |
curl -X GET "http://localhost:9200/blog/_search?pretty=true" -d '{ "query": { "query_string": { "query": "more AND help" } } }' | |
{ | |
"took" : 2, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 1, | |
"max_score" : 0.0958915, | |
"hits" : [ { | |
"_index" : "blog", | |
"_type" : "doc", | |
"_id" : "WDa3gL8yRxGk8GGrQm2WBA", | |
"_score" : 0.0958915, "_source" : { "title" : "some title 1", "summary" : "some summary 1", "tags" : "@@more-help", "user_id" : 1 } | |
} ] | |
} | |
} | |
curl -X GET "http://localhost:9200/blog/_search?pretty=true" -d '{ "query": { "query_string": { "query": "more*" } } }' | |
{ | |
"took" : 1, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 3, | |
"max_score" : 1.0, | |
"hits" : [ { | |
"_index" : "blog", | |
"_type" : "doc", | |
"_id" : "-awdsUwIRA20IcP1TMsRNw", | |
"_score" : 1.0, "_source" : { "title" : "some title 3", "summary" : "some summary 3", "tags" : "@@more-info", "user_id" : 11 } | |
}, { | |
"_index" : "blog", | |
"_type" : "doc", | |
"_id" : "WDa3gL8yRxGk8GGrQm2WBA", | |
"_score" : 1.0, "_source" : { "title" : "some title 1", "summary" : "some summary 1", "tags" : "@@more-help", "user_id" : 1 } | |
}, { | |
"_index" : "blog", | |
"_type" : "doc", | |
"_id" : "s0rynjY4Rb-O6_RskE6CxQ", | |
"_score" : 1.0, "_source" : { "title" : "some title 2", "summary" : "some summary 2", "tags" : "@@more-sugar", "user_id" : 2 } | |
} ] | |
} | |
} | |
# Should not_analyzed fields be analyzed for the _all field? | |
# Shouldnt the not_analyzed field have its not_analyzed content in the _all field? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment