ElastcSearch-使用“ docvalue_fields”在检索结果时获取未排序的数据

时间:2018-06-25 10:48:04

标签: elasticsearch

我正在尝试使用docvalue_fields字段中的text检索数据。下面是映射:

PUT dvtest
{
  "settings": {
    "index": {
      "analysis": {
        "tokenizer": {
          "nl-tokenizer": {
            "type": "simple_pattern_split",
                "pattern": "\n|\r\n|\r|\n\r"
          }
        },
        "analyzer": {
          "newline": {
            "type": "custom",
            "filter": [
              "trim"
            ],
            "tokenizer": "nl-tokenizer"
          }
        }
      }
    }
  },
  "mappings": {
    "indexMapping": {
      "properties": {
        "data": {
          "norms": false,
          "type": "text",
          "analyzer": "newline",
          "fielddata": true
        }
      }
    }
  }
}

查询以将样本数据放入索引:

POST dvtest/indexMapping
{
  "data":"""
  The quick brown fox 
Jumps over the lazy dog
"""
}

我用于检索数据的查询:

POST dvtest/indexMapping/_search
{
  "_source": false
  , "docvalue_fields": ["data"]
}

现在,当我尝试使用上述查询检索数据时,得到的结果如下所示。数据字段中的令牌按字母顺序排序,我想按索引顺序检索它。

 "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "dvtest",
        "_type": "indexMapping",
        "_id": "Kp5jNmQBrlmAX-4PVbm9",
        "_score": 1,
        "fields": {
          "data": [
            "Jumps over the lazy dog",
            "The quick brown fox"
          ]
        }
      }
    ]
  }

所以,我想要的结果是:

...
"fields": {
          "data": [
            "The quick brown fox",
            "Jumps over the lazy dog"
          ]
        }
...

我尝试在Google上搜索帮助,还检查了GitHub,但找不到有用的东西!

在此先感谢您的帮助! :)

0 个答案:

没有答案