[英]How to search in ElasticSearch the most common word of a single field in a single document?
How to search in ElasticSearch the most common word of a single field in a single document?如何在 ElasticSearch 中搜索单个文档中单个字段的最常见单词? Lets say I have a document that have a field "pdf_content" of type keyword containing:
假设我有一个文档,其中包含一个关键字类型的字段“pdf_content”,其中包含:
"good polite nice good polite good" “客气不错不错客气不错”
I would like a return of我想要退货
{
word: good,
occurences: 3
},
{
word: polite,
occurences: 2
},
{
word: nice,
occurences: 1
},
How is this possible using ElasticSearch 7.15?这怎么可能使用 ElasticSearch 7.15?
I tried this in the Kibana console:我在 Kibana 控制台中尝试了这个:
GET /pdf/_search
{
"aggs": {
"pdf_contents": {
"terms": { "field": "pdf_content" }
}
}
}
But it only returns me the list of PDFs i have indexed.但它只返回我已编入索引的 PDF 列表。
Have you ever tried term_vector ?:你有没有试过term_vector ?:
Basically, you can do:基本上,你可以这样做:
Mappings:映射:
{
"mappings": {
"properties": {
"pdf_content": {
"type": "text",
"term_vector": "with_positions_offsets_payloads"
}
}
}
}
with your sample document:使用您的示例文档:
POST /pdf/_doc/1
{
"pdf_content": "good polite nice good polite good"
}
Then you can do:然后你可以这样做:
GET /pdf/_termvectors/1
{
"fields" : ["pdf_content"],
"offsets" : false,
"payloads" : false,
"positions" : false,
"term_statistics" : false,
"field_statistics" : false
}
If you want to see other information, you can set them to true
.如果您想查看其他信息,可以将它们设置为
true
。 Set all to false
give you what you want.将所有设置为
false
给你你想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.