this is a test about term query ,but result is no ideal
PUT /abc
{
"mapping": {
"abc": {
"properties": {
"str2": {
"type": "string",
"index":"not_analyzed"
}
}
}
},
"settings": {
"number_of_replicas": 1,
"number_of_shards": 1
}
}
POST /abc/abc/1?pretty
{
"str1": "hello, world!",
"str2": "goodbye! 你好"
}
POST /abc/abc/2?pretty
{
"str1": "hello",
"str2": "你好"
}
POST /abc/abc/3?pretty
{
"str1": "hello",
"str2": "goodbye"
}
###query one:
GET /abc/_search
{
"query": {
"term": {
"str2": {
"value": "goodbye"
}
}
}
}
###result:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 0.59086174,
"hits": [
{
"_index": "abc",
"_type": "abc",
"_id": "3",
"_score": 0.59086174,
"_source": {
"str1": "hello",
"str2": "goodbye"
}
},
{
"_index": "abc",
"_type": "abc",
"_id": "1",
"_score": 0.33355096,
"_source": {
"str1": "hello, world!",
"str2": "goodbye! 你好"
}
}
]
}
}
Result is right, but query two...
query two:
GET /abc/_search
{
"query": {
"term": {
"str2": {
"value": "你好"
}
}
}
}
###result:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
while term's value is Chinese , no result ? this is why ?
str2 is not_analyzed