世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。
问 :rank_feature有什么特点?
答 :
问 :rank_feature如何使用?
答 :
# rank_feature
PUT /rank_feature_test
{
"mappings" : {
"properties" : {
"my_pagerank" : {"type" : "rank_feature"},
"my_url_length" : {
"type" : "rank_feature",
"positive_score_impact" : false
}
}
}
}
# 索引
POST /rank_feature_test/_doc
{
"my_pagerank" : 10,
"my_url_length" : 20
}
# 索引
POST /rank_feature_test/_doc
{
"my_pagerank" : 10,
"my_url_length" : 15
}
# 索引
POST /rank_feature_test/_doc
{
"my_pagerank" : 12,
"my_url_length" : 20
}
# 索引
POST /rank_feature_test/_doc
{
"my_pagerank" : 12,
"my_url_length" : 15
}
# 搜索
GET /rank_feature_test/_search
{
"query" : {
"rank_feature" : {
"field" : "my_url_length"
}
}
}
# 结果
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 4,
"relation" : "eq"
},
"max_score" : 0.537931,
"hits" : [
{
"_index" : "rank_feature_test",
"_type" : "_doc",
"_id" : "Xh-zcXgBLGzotGjRqlxs",
"_score" : 0.537931,
"_source" : {
"my_pagerank" : 10,
"my_url_length" : 15
}
},
{
"_index" : "rank_feature_test",
"_type" : "_doc",
"_id" : "YB-zcXgBLGzotGjRwVwV",
"_score" : 0.537931,
"_source" : {
"my_pagerank" : 12,
"my_url_length" : 15
}
},
{
"_index" : "rank_feature_test",
"_type" : "_doc",
"_id" : "XR-zcXgBLGzotGjRnFxM",
"_score" : 0.46583146,
"_source" : {
"my_pagerank" : 10,
"my_url_length" : 20
}
},
{
"_index" : "rank_feature_test",
"_type" : "_doc",
"_id" : "Xx-zcXgBLGzotGjRtFzP",
"_score" : 0.46583146,
"_source" : {
"my_pagerank" : 12,
"my_url_length" : 20
}
}
]
}
}
# 搜索
GET /rank_feature_test/_search
{
"query" : {
"rank_feature" : {
"field" : "my_pagerank"
}
}
}
# 结果
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 4,
"relation" : "eq"
},
"max_score" : 0.5217391,
"hits" : [
{
"_index" : "rank_feature_test",
"_type" : "_doc",
"_id" : "Xx-zcXgBLGzotGjRtFzP",
"_score" : 0.5217391,
"_source" : {
"my_pagerank" : 12,
"my_url_length" : 20
}
},
{
"_index" : "rank_feature_test",
"_type" : "_doc",
"_id" : "YB-zcXgBLGzotGjRwVwV",
"_score" : 0.5217391,
"_source" : {
"my_pagerank" : 12,
"my_url_length" : 15
}
},
{
"_index" : "rank_feature_test",
"_type" : "_doc",
"_id" : "XR-zcXgBLGzotGjRnFxM",
"_score" : 0.47619045,
"_source" : {
"my_pagerank" : 10,
"my_url_length" : 20
}
},
{
"_index" : "rank_feature_test",
"_type" : "_doc",
"_id" : "Xh-zcXgBLGzotGjRqlxs",
"_score" : 0.47619045,
"_source" : {
"my_pagerank" : 10,
"my_url_length" : 15
}
}
]
}
}