世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。
问 :term_vector有什么特点?
答 :
问 :term_vector如何使用?
答 :
# term_vector
PUT /term_vector_test
{
"mappings" : {
"properties" : {
"name" : {
"type" : "text",
"term_vector" : "with_positions_offsets"
}
}
}
}
# 索引
POST /term_vector_test/_doc/1
{
"name" : "hello good me"
}
# 搜索
GET /term_vector_test/_search
{
"query" : {
"match" : {
"name" : "hello"
}
},
"highlight" : {
"fields" : {
"name" : {}
}
}
}
# 结果
{
"took" : 850,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 0.2876821,
"hits" : [
{
"_index" : "term_vector_test",
"_type" : "_doc",
"_id" : "1",
"_score" : 0.2876821,
"_source" : {
"name" : "hello good me"
},
"highlight" : {
"name" : [
"<em>hello</em> good me"
]
}
}
]
}
}