栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何获得Elasticsearch文档中每个单词的总数?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何获得Elasticsearch文档中每个单词的总数?

您正在寻找

termvectors
利用分析仪的。这样做时,您可以定义所需的任何分析器,即阻止分析器将单词转换为根/普通形式。查看文档以获取更多详细信息。

在:

POST so/_closePUT so/_settings{  "settings": {    "analysis":{       "analyzer": {        "my_analyzer": {          "type": "custom",          "tokenizer": "standard",          "filter": ["lowercase", "my_stemmer"]        }      },      "filter": {        "my_stemmer": {          "type": "stemmer",          "name": "english"        }      }    }  }}POST so/_openPUT so/t1/_mapping{  "t1": {    "properties": {      "tweet": {        "type": "string",        "store": true,        "index_analyzer": "my_analyzer"      }    }  }}POST so/t1/1{"tweet": "It is so boring here I want to go to my home sweet home. So I'm bored"}

出:

{   "_index": "so",   "_type": "t1",   "_id": "1",   "_version": 2,   "found": true,   "term_vectors": {      "tweet": {         "field_statistics": { "sum_doc_freq": 13, "doc_count": 1, "sum_ttf": 17         },         "terms": { "bore": {    "term_freq": 2,    ... }, "go": {    "term_freq": 1,    ... }, "here": {    "term_freq": 1,    ... }, "home": {    "term_freq": 2,    ... }, "i": {    "term_freq": 1,    ... }, "i'm": {    "term_freq": 1,    ... }, "is": {    "term_freq": 1,    ... }, "it": {    "term_freq": 1,    ... }, "my": {    "term_freq": 1,    ... }, "so": {    "term_freq": 2,    ... }, "sweet": {    "term_freq": 1,    ... }, "to": {    "term_freq": 2,    ... }, "want": {    "term_freq": 1,    ... }         }      }   }}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/403649.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号