重点
- 统计 term 相关数据
- ttf: total term frequency
- df: document frequency
- dc: document count
- term_freq: term 出现频率
_termvectors
PUT /twitter
{ "mappings": {
"properties": {
"text": {
"type": "text",
"term_vector": "with_positions_offsets_payloads",
"store" : true,
"analyzer" : "fulltext_analyzer"
},
"fullname": {
"type": "text",
"term_vector": "with_positions_offsets_payloads",
"analyzer" : "fulltext_analyzer"
}
}
},
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
},
"analysis": {
"analyzer": {
"fulltext_analyzer": {
"type": "custom",
"tokenizer": "whitespace",
"filter": [
"lowercase",
"type_as_payload"
]
}
}
}
}
}
PUT /twitter/_doc/1
{
"fullname" : "John Doe",
"text" : "twitter test test test "
}
PUT /twitter/_doc/2
{
"fullname" : "Jane Doe",
"text" : "Another twitter test ..."
}
GET /twitter/_termvectors/1
{
"fields" : ["text"],
"offsets" : true,
"payloads" : true,
"positions" : true,
"term_statistics" : true,
"field_statistics" : true
}
GET /twitter/_termvectors/1
{
"fields" : ["text", "some_field_without_term_vectors"],
"offsets" : true,
"positions" : true,
"term_statistics" : true,
"field_statistics" : true
}
GET /twitter/_termvectors
{
"doc" : {
"fullname" : "John Doe",
"text" : "twitter test test test"
}
}
GET /twitter/_termvectors
{
"doc" : {
"fullname" : "John Doe",
"text" : "twitter test test test"
},
"fields": ["fullname"],
"per_field_analyzer" : {
"fullname": "keyword"
}
}
GET /twitter/_termvectors
{
"doc": {
"fullname": "When when when wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.",
"text": "twitter test test test"
},
"fields": [
"fullname"
],
"per_field_analyzer": {
"fullname": "custom"
},
"term_statistics": true,
"field_statistics": true,
"positions": false,
"offsets": false,
"filter": {
"max_num_terms": 3,
"min_term_freq": 2,
"min_doc_freq": 1
}
}
_mtermvectors
POST /_mtermvectors
{
"docs": [
{
"_index": "twitter",
"_id": "2",
"term_statistics": true
},
{
"_index": "twitter",
"_id": "1",
"fields": [
"text"
]
}
]
}
POST /twitter/_mtermvectors
{
"docs": [
{
"_id": "2",
"fields": [
"text"
],
"term_statistics": true
},
{
"_id": "1"
}
]
}
POST /twitter/_mtermvectors
{
"ids" : ["1", "2"],
"parameters": {
"fields": [
"text"
],
"term_statistics": true
}
}
POST /_mtermvectors
{
"docs": [
{
"_index": "twitter",
"doc" : {
"fullname" : "John Doe",
"text" : "twitter test test test"
}
},
{
"_index": "twitter",
"doc" : {
"fullname" : "Jane Doe",
"text" : "Another twitter test ..."
}
}
]
}