我正在开发一个命令,它读取文件并将数据存储在mongoDB数据库中。对于搜索实例,我正在使用弹性搜索。我已经使用了exercise / elastica-bundle。
当我为索引创建映射时,我收到“dob”字段的错误。
MapperParsingException[failed to parse [dob]];
nested: MapperParsingException[failed to parse date field [], tried both date
format [dateOptionalTime], and timestamp number with locale [null]]; nested:
IllegalArgumentException[Invalid format: ""];
这是我在config.yml文件中的映射:
person:
mappings:
name: { index: not_analyzed }
title: { index: not_analyzed }
dob: { index: not_analyzed }
position: { index: not_analyzed }
address: { index: not_analyzed }
postCode: { index: not_analyzed }
country: { index: not_analyzed }
otherInformation: { index: not_analyzed }
persistence:
driver: mongodb
model: MDM\MainBundle\Document\Person
provider: ~
listener: ~
finder: ~
如果我提供,
dob: { type: date, format: "yyyy-mm-dd", index: not_analyzed }
它给了我错误,
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized options "format" under "foq_elastica.indexes.storage.types.list.mappings.dob"
编辑: 我还没有找到任何解决方案,但是现在我做了这个
dob: { type: string, index: not_analyzed }
现在我可以进入弹性指数。
答案 0 :(得分:0)
elasticSearch中有几个"default" date format。您应该检查是否找到符合您需求的相应模式。如果不这样做,您也可以进行自定义格式化日期。
然后您的格式可能是basic_date,格式如下:
dob: { type: date, format: "yyyyMMdd", index: not_analyzed }