Gil*_*ere 8 elasticsearch elasticsearch-5
测试数据:
curl -XPUT 'localhost:9200/customer/external/1?pretty' -d '{ "body": "this is a test" }'
curl -XPUT 'localhost:9200/customer/external/2?pretty' -d '{ "body": "and this is another test" }'
curl -XPUT 'localhost:9200/customer/external/2?pretty' -d '{ "body": "this thing is a test" }'
Run Code Online (Sandbox Code Playgroud)
我的目标是获取文档中短语的频率.
我知道如何获得文档中术语的频率:
curl -g "http://localhost:9200/customer/external/1/_termvectors?pretty" -d'
{
"fields": ["body"],
"term_statistics" : true
}'
Run Code Online (Sandbox Code Playgroud)
我知道如何计算包含给定短语的文档(使用match_phrase或span_near查询):
curl -g "http://localhost:9200/customer/_count?pretty" -d'
{
"query": {
"match_phrase": {
"body" : "this is"
}
}
}'
Run Code Online (Sandbox Code Playgroud)
如何访问短语的频率?
您可以使用术语向量。正如文档中所写
返回值编辑
可以请求三种类型的值:术语信息、术语统计和字段统计。默认情况下,返回所有字段的所有术语信息和字段统计信息,但不返回术语统计信息。术语信息编辑
Run Code Online (Sandbox Code Playgroud)term frequency in the field (always returned) term positions (positions : true) start and end offsets (offsets : true) term payloads (payloads : true), as base64 encoded bytes
你必须达到术语频率 - 在示例中你可以看到 doc 中存在 john doe 的频率。请注意 termvector 会重复应用它的字段的磁盘空间占用
| 归档时间: |
|
| 查看次数: |
368 次 |
| 最近记录: |