从字段中提取关键字
Extract keywords from fields
我想编写一个查询来分析一个或多个字段?
即当前的分析器需要文本才能运行,而不是传递文本我想传递一个字段值。
如果我有这样的文档
{
"desc": "A document description",
"name": "This name is not original",
"amount": 3000
}
我想要return类似下面的东西
{
"desc": ["document", "description"],
"name": ["name", "original"],
"amount": 3000
}
您可以使用 Term Vectors 或 Multi Term Vectors 来实现您想要的:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html
您必须指定您想要的字段的 Ids 以及字段,它会 return 为您的每个文档分析标记的数组以及您可以轻松禁用的某些其他信息。
GET /exampleindex/_doc/_mtermvectors
{
"ids": [
"1","2"
],
"parameters": {
"fields": [
"*"
]
}
}
会 return 类似的东西吗:
"docs": [
{
"_index": "exampleindex",
"_type": "_doc",
"_id": "1",
"_version": 2,
"found": true,
"took": 0,
"term_vectors": {
"desc": {
"field_statistics": {
"sum_doc_freq": 5,
"doc_count": 2,
"sum_ttf": 5
},
"terms": {
"amazing": {
"term_freq": 1,
"tokens": [
{
"position": 1,
"start_offset": 3,
"end_offset": 10
}
]
},
"an": {
"term_freq": 1,
"tokens": [
{
"position": 0,
"start_offset": 0,
"end_offset": 2
}
]
}
我想编写一个查询来分析一个或多个字段?
即当前的分析器需要文本才能运行,而不是传递文本我想传递一个字段值。
如果我有这样的文档
{
"desc": "A document description",
"name": "This name is not original",
"amount": 3000
}
我想要return类似下面的东西
{
"desc": ["document", "description"],
"name": ["name", "original"],
"amount": 3000
}
您可以使用 Term Vectors 或 Multi Term Vectors 来实现您想要的:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html
您必须指定您想要的字段的 Ids 以及字段,它会 return 为您的每个文档分析标记的数组以及您可以轻松禁用的某些其他信息。
GET /exampleindex/_doc/_mtermvectors
{
"ids": [
"1","2"
],
"parameters": {
"fields": [
"*"
]
}
}
会 return 类似的东西吗:
"docs": [
{
"_index": "exampleindex",
"_type": "_doc",
"_id": "1",
"_version": 2,
"found": true,
"took": 0,
"term_vectors": {
"desc": {
"field_statistics": {
"sum_doc_freq": 5,
"doc_count": 2,
"sum_ttf": 5
},
"terms": {
"amazing": {
"term_freq": 1,
"tokens": [
{
"position": 1,
"start_offset": 3,
"end_offset": 10
}
]
},
"an": {
"term_freq": 1,
"tokens": [
{
"position": 0,
"start_offset": 0,
"end_offset": 2
}
]
}