世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。
问 :ignore_above有什么特点?
答 :
问 :ignore_above如何使用?
答 :
# ignore_above
PUT /ignore_above_test
{
"mappings" : {
"properties" : {
"name" : {
"type" : "keyword",
"ignore_above" : 10
}
}
}
}
# 索引
POST /ignore_above_test/_doc/1
{
"name" : "hello"
}
# 索引
POST /ignore_above_test/_doc/2
{
"name" : "hello good"
}
# 索引
POST /ignore_above_test/_doc/3
{
"name" : "hello good me"
}
# 搜索
GET /ignore_above_test/_search
{
"aggs" : {
"ignore_above_term_field" : {
"terms" : {
"field" : "name"
}
}
}
}
# 结果
{
"took" : 504,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "ignore_above_test",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"name" : "hello"
}
},
{
"_index" : "ignore_above_test",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"name" : "hello good"
}
},
{
"_index" : "ignore_above_test",
"_type" : "_doc",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"name" : "hello good me"
}
}
]
},
"aggregations" : {
"ignore_above_term_field" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "hello",
"doc_count" : 1
},
{
"key" : "hello good",
"doc_count" : 1
}
]
}
}
}