世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。
问 :percolator有什么特点?
答 :
问 :percolator如何使用?
答 :
# percolator
PUT /percolator_test
{
"mappings" : {
"properties" : {
"my_percolator" : {"type" : "percolator"},
"my_text" : {"type" : "text"}
}
}
}
# 索引
POST /percolator_test/_doc/1
{
"my_percolator" : {
"match" : {
"my_text" : "hello"
}
}
}
# 索引
POST /percolator_test/_doc/2
{
"my_percolator" : {
"match" : {
"my_text" : "hello good"
}
}
}
# 索引
POST /percolator_test/_doc/3
{
"my_percolator" : {
"match" : {
"my_text" : "good"
}
}
}
# 索引
POST /percolator_test/_doc/4
{
"my_percolator" : {
"match" : {
"my_text" : "tea"
}
}
}
# 搜索
GET /percolator_test/_search
{
"query" : {
"percolate": {
"field" : "my_percolator",
"document" : {
"my_text" : "this is hello good"
}
}
}
}
# 结果
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : 0.26152915,
"hits" : [
{
"_index" : "percolator_test",
"_type" : "_doc",
"_id" : "2",
"_score" : 0.26152915,
"_source" : {
"my_percolator" : {
"match" : {
"my_text" : "hello good"
}
}
},
"fields" : {
"_percolator_document_slot" : [
0
]
}
},
{
"_index" : "percolator_test",
"_type" : "_doc",
"_id" : "1",
"_score" : 0.13076457,
"_source" : {
"my_percolator" : {
"match" : {
"my_text" : "hello"
}
}
},
"fields" : {
"_percolator_document_slot" : [
0
]
}
},
{
"_index" : "percolator_test",
"_type" : "_doc",
"_id" : "3",
"_score" : 0.13076457,
"_source" : {
"my_percolator" : {
"match" : {
"my_text" : "good"
}
}
},
"fields" : {
"_percolator_document_slot" : [
0
]
}
}
]
}
}