個人的メモ
準備
$ curl -XPUT localhost:9200/test_idx/test_type/1 -d '{"test_str": "foo"}'
{"_index":"test_idx","_type":"test_type","_id":"1","_version":1,"created":true}
$ curl -XPUT localhost:9200/test_idx/test_type/2 -d '{"test_str": ""}'
{"_index":"test_idx","_type":"test_type","_id":"2","_version":1,"created":true}
$ curl -XPUT localhost:9200/test_idx/test_type/3 -d '{"test_str": null}'
{"_index":"test_idx","_type":"test_type","_id":"3","_version":1,"created":true}
filtering
exitis filter
GET test_idx/test_type/_search
{
"filter": {
"exists": {
"field": "test_str"
}
}
}
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 1,
"hits": [
{
"_index": "test_idx",
"_type": "test_type",
"_id": "1",
"_score": 1,
"_source": {
"test_str": "foo"
}
},
{
"_index": "test_idx",
"_type": "test_type",
"_id": "2",
"_score": 1,
"_source": {
"test_str": ""
}
}
]
}
}
missing filter
GET test_idx/test_type/_search
{
"filter": {
"missing": {
"field": "test_str"
}
}
}
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "test_idx",
"_type": "test_type",
"_id": "3",
"_score": 1,
"_source": {
"test_str": null
}
}
]
}
}
term filter (by empty string)
GET test_idx/test_type/_search
{
"filter": {
"term": {
"test_str": ""
}
}
}
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}