admin管理员组文章数量:1566668
世界上并没有完美的程序,但是我们并不因此而沮丧,因为写程序就是一个不断追求完美的过程。
问:significant_text有什么特点?
答:
问:significant_text如何使用?
答:
# 删除
DELETE /significant_text_test
# 映射
PUT /significant_text_test
{
"mappings": {
"properties": {
"name": {"type": "text"},
"filter_type": {"type": "keyword"}
}
}
}
# 索引
POST /significant_text_test/_bulk?routing=1&refresh
{"index": {"_id": 1}}
{"name": "hello good", "filter_type": "t1"}
{"index": {"_id": 2}}
{"name": "me good", "filter_type": "t2"}
{"index": {"_id": 3}}
{"name": "me hello", "filter_type": "t1"}
{"index": {"_id": 4}}
{"name": "server hello good me", "filter_type": "t1"}
{"index": {"_id": 5}}
{"name": "service me good hello", "filter_type": "t1"}
{"index": {"_id": 6}}
{"name": "redis hello good", "filter_type": "t2"}
{"index": {"_id": 7}}
{"name": "redis good me", "filter_type": "t1"}
{"index": {"_id": 8}}
{"name": "redis good hello", "filter_type": "t1"}
# 搜索
GET /significant_text_test/_search?size=0
{
"query": {
"match": {
"name": "hello"
}
},
"aggs": {
"key_name_aggs": {
"significant_text": {
"field": "name",
"min_doc_count": 4,
"filter_duplicate_text": true,
"background_filter": {
"term": {
"filter_type": "t1"
}
}
}
}
}
}
# 结果
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 6,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"key_name_aggs" : {
"doc_count" : 6,
"bg_count" : 5,
"buckets" : [
{
"key" : "hello",
"doc_count" : 6,
"score" : 0.24999999999999994,
"bg_count" : 4
},
{
"key" : "good",
"doc_count" : 5,
"score" : 0.03472222222222222,
"bg_count" : 4
}
]
}
}
}
本文标签: ElasticsearchesaggssignificanttextBucket
版权声明:本文标题:es - elasticsearch - aggs - bucket - significant_text 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1725721097a1038384.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论