在字段名称中使用通配符multi_match查询以匹配整个字段

时间:2017-06-01 06:15:47

标签: elasticsearch

Using Wildcards in Field Names表示可以使用通配符指定字段名称,例如:

{
    "multi_match": {
        "query":  "Quick brown fox",
        "fields": "*_title"
    }
}

现在我想查询索引中的所有字段,因此我尝试使用*来匹配所有字段。但是我收到了一个错误,例如:

{
    "multi_match": {
      "query": "nanjing jianye",
      "fields": ["*"]
    }
}

错误:

{
   "error": {
      "root_cause": [
         {
            "type": "illegal_argument_exception",
            "reason": "Invalid format: \"nanjing jianye\""
         }
      ],
      "type": "search_phase_execution_exception",
      "reason": "all shards failed",
      "phase": "query",
      "grouped": true,
      "failed_shards": [
         {
            "shard": 0,
            "index": "mycustomer",
            "node": "YHKU1KllRJW-BiH9g5-McQ",
            "reason": {
               "type": "illegal_argument_exception",
               "reason": "Invalid format: \"nanjing jianye\""
            }
         }
      ]
   },
   "status": 400
}

如何使用通配符匹配整个字段,而不是显式指定字段?

0 个答案:

没有答案