![](/img/trans.png)
[英]How to query a single field from a Firestore document in REST API?
[英]How to search in ElasticSearch the most common word of a single field in a single document?
如何在 ElasticSearch 中搜索单个文档中单个字段的最常见单词? 假设我有一个文档,其中包含一个关键字类型的字段“pdf_content”,其中包含:
“客气不错不错客气不错”
我想要退货
{
word: good,
occurences: 3
},
{
word: polite,
occurences: 2
},
{
word: nice,
occurences: 1
},
这怎么可能使用 ElasticSearch 7.15?
我在 Kibana 控制台中尝试了这个:
GET /pdf/_search
{
"aggs": {
"pdf_contents": {
"terms": { "field": "pdf_content" }
}
}
}
但它只返回我已编入索引的 PDF 列表。
你有没有试过term_vector ?:
基本上,你可以这样做:
映射:
{
"mappings": {
"properties": {
"pdf_content": {
"type": "text",
"term_vector": "with_positions_offsets_payloads"
}
}
}
}
使用您的示例文档:
POST /pdf/_doc/1
{
"pdf_content": "good polite nice good polite good"
}
然后你可以这样做:
GET /pdf/_termvectors/1
{
"fields" : ["pdf_content"],
"offsets" : false,
"payloads" : false,
"positions" : false,
"term_statistics" : false,
"field_statistics" : false
}
如果您想查看其他信息,可以将它们设置为true
。 将所有设置为false
给你你想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.