【发布时间】:2020-09-20 04:32:53
【问题描述】:
我有这样的 Elasticsearch 数据-
PUT /text/_doc/1
{
"name": "pdf1",
"text":"For the past six weeks. The unemployment crisis has unfolded so suddenly and rapidly."
}
PUT /text/_doc/2
{
"name": "pdf2",
"text":"The unemployment crisis has unfolded so suddenly and rapidly."
}
在此示例中,我正在进行全文搜索,我正在搜索“文本”字段中具有“失业”子字符串的所有文档。最后,我希望所有文档按“文本”字段中“失业”字符串的索引值的升序排序。例如 - 子字符串“unemployment”首先出现在 doc2 中的索引“4”处,所以我希望该文档首先在结果中返回。
GET /text/_search?pretty
{
"query": {
"match": {
"text": "unemployment"
}
}
}
我尝试了一些类似 term_vector 的东西,这是我使用的映射,但没有帮助。
PUT text/_mapping
{
"properties": {
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword"
}
}
},
"text" : {
"type" : "text",
"term_vector": "with_positions_offsets"
}
}
}
谁能帮我制作正确的映射和搜索查询?
提前致谢!
【问题讨论】:
标签: elasticsearch elasticsearch-aggregation elasticsearch-query