弹性搜索失败,说索引不支持日期格式

弗莱德

我无法使用日期格式进行弹性搜索

我创建了一个索引,并且字段映射显示为日期格式,但是查询失败。

在加载数据之前,我创建了带有映射的索引,并将数据加载到弹性搜索中。

  "mappings": {
     "workers": {
        "person.birthDate": {
           "full_name": "person.birthDate",
           "mapping": {
              "birthDate": {
                 "type": "date",
                 "format": "yyyy-MM-dd||epoch_millis"
              }
           }
        }

我的输入查询如下

POST _search
{
   "query": {


  "bool" : {
    "must" : [ {
      "match" : {
        "person.birthDate" : {
          "query" : "1968-06-15",
          "type" : "date"
        }
      }
    } ]
  }



   },
   "from": 0,
   "size": 10,
   "sort": [],
   "aggs": {}
}

和输出是

{
   "error": {
      "root_cause": [
         {
            "type": "query_parsing_exception",
            "reason": "[match] query does not support type date",
            "index": "index1",
            "line": 9,
            "col": 33
         }
      ],
      "type": "search_phase_execution_exception",
      "reason": "all shards failed",
      "phase": "query",
      "grouped": true,
      "failed_shards": [
         {
            "shard": 0,
            "index": "index1",
            "node": "RewaFar_TsGVGz1RmgOxlA",
            "reason": {
               "type": "query_parsing_exception",
               "reason": "[match] query does not support type date",
               "index": "index1",
               "line": 9,
               "col": 33
            }
         }
      ]
   },
   "status": 400
}

任何帮助,将不胜感激。请注意,弹性搜索非常新。

吉蒂

以上不是有效的match查询。type:date不是匹配查询的有效选项。
如果要按日期过滤,建议使用范围查询

例子:

put test 
{
    "mappings": {
        "test": {
               "properties" : {
                    "birthDate": {
                        "type": "date",
                        "format": "yyyy-MM-dd||epoch_millis"
                    }
               }
           }
    }
}

put test/test/1 
{
    "birthDate" : "2016-05-20"
}

##timestamp for 2016-05-20 19:00:24 GMT
put test/test/2
{
    "birthDate" : 1463771107000
}

post test/test/_search
{
    "query": {
       "range" : {
            "birthDate" : {
                "gte" : "2016-05-20",
                "lt" :  "2016-05-21",
                 "format": "yyyy-MM-dd||epoch_millis"
             }
    }
}


    "hits": [
     {
        "_index": "test",
        "_type": "test",
        "_id": "2",
        "_score": 1,
        "_source": {
           "birthDate": 1463771107000
        }
     },
     {
        "_index": "test",
        "_type": "test",
        "_id": "1",
        "_score": 1,
        "_source": {
           "birthDate": "2016-05-20"
        }
     }
  ]

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

弹性搜索失败,说索引不支持日期格式

来自分类Dev

SparkSql不支持日期格式

来自分类Dev

SparkSql不支持日期格式

来自分类Dev

不支持MySQL日期格式

来自分类Dev

DotNetZip失败,显示“流不支持搜索操作”

来自分类Dev

DotNetZip失败,显示“流不支持搜索操作”

来自分类Dev

不支持复制项目失败的给定路径格式

来自分类Dev

杰克逊不支持ISO日期格式

来自分类Dev

不支持URI格式

来自分类Dev

弹性搜索创建索引 - 失败

来自分类Dev

为什么InnoDB不支持全文搜索索引,而MyISAM却支持它?

来自分类Dev

fallocate失败:不支持该操作

来自分类Dev

TypeError:“ OrientRecord”对象不支持索引

来自分类Dev

类型化地图不支持索引

来自分类Dev

TypeError:“ int”对象不支持索引

来自分类Dev

Django:“用户”对象不支持索引

来自分类Dev

golang,int类型不支持索引

来自分类Dev

'Symbol'对象不支持索引

来自分类Dev

TypeError:对象不支持索引

来自分类Dev

“用户”对象不支持索引

来自分类Dev

TypeError:“ dict”对象不支持索引

来自分类Dev

Django:“用户”对象不支持索引

来自分类Dev

'Symbol'对象不支持索引

来自分类Dev

TypeError:“ GitHubIterator”对象不支持索引

来自分类Dev

ValueError:不支持的格式字符'

来自分类Dev

错误:不支持给定路径的格式

来自分类Dev

ValueError:不支持多类格式

来自分类Dev

python不支持RSA密钥格式

来自分类Dev

highchart不支持JSON格式