elasticsearch,elastica,Php,Symfony,elasticsearch,Elastica" /> elasticsearch,elastica,Php,Symfony,elasticsearch,Elastica" />

Php 批量请求中出错:[arg]无法从类型[long]更改为[float]

Php 批量请求中出错:[arg]无法从类型[long]更改为[float],php,symfony,elasticsearch,elastica,Php,Symfony,elasticsearch,Elastica,我的FOSElastica包配置有问题。我使用JMS序列化程序,并尝试添加具有字段的对象,这些字段实际上包含json数组。但是,当我尝试填充其中一些时,会出现以下错误: Error in one or more bulk request actions: index: /table_conten

我的FOSElastica包配置有问题。我使用JMS序列化程序,并尝试添加具有字段的对象,这些字段实际上包含json数组。但是,当我尝试填充其中一些时,会出现以下错误:

  Error in one or more bulk request actions:                                                                                                 

  index: /table_content/table_content/10 caused mapper [corrected_value_float.args.argument1] cannot be changed from type [long] to [float]  
  index: /table_content/table_content/11 caused mapper [difference_value_float.entry] cannot be changed from type [float] to [long]  
目前,我很难理解他是如何推断json数组中的参数类型的。明确地说,我认为JMS只是将对象像任何其他对象一样序列化,并将{“field”:“value”}关联为json,这里数据库中的“value”是一个实际的json数组,因此elastica对其进行索引,并对数组的值进行某种“猜测”类型

/table_content/table_content/10的json数组有问题(我猜他不喜欢“argument1”结尾的100):

/table_content/table_content/11的json数组有问题:

{"args": {
"entry":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
}
}
对于第二个有问题的数组,我甚至不明白为什么他认为其中一个数字是浮点数,而它只由0组成


即使我对其余的对象使用序列化程序,我怎么能告诉他json数组值的类型呢?elastica bundle在何处“猜测”这些数组中的类型?

如果您不提供映射,Elasticsearch将根据它索引的第一个文档创建映射。尝试检查索引的_映射。为了避免这种情况,您可以自己指定映射。

因此,一段时间后,我找到了解决问题的方法:和

事实上,ElasticSearch无法识别某些类型的字段(如date或geo_point),因此我在模板的帮助下强制将它们用于特定命名的字段

如果您想要我在FOSElastica()中的配置示例:


Elasticsearch将根据它索引的第一个文档创建映射(如果您不提供)。尝试检查索引的
\u映射。为了避免这种情况,你可以自己指定一个映射。哦,这是有意义的,因为我自己在FOSElastica代码中找不到任何东西来指定它。因此,我唯一的解决方案是创建自己的映射,而不是依赖序列化程序。。。我会明白的,谢谢你的提醒因为我的评论似乎已经解决了你的问题,我将提供它作为一个答案,这样你就可以将它标记为可接受的解决方案。很高兴能提供帮助,funWell没有解决我的问题,我不能用FOSElastica真正做到这一点,我必须手动完成映射(我有50个表,每个表有几十个字段,有些字段相互关联)。但它回答了当没有显式定义类型时ElasticSearch如何创建映射的问题,谢谢。
{"args": {
"entry":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
}
}
fos_elastica:
    serializer: 
        serializer: jms_serializer
    clients:
        default: 
            host: localhost 
            port: 9200
    index_templates: # https://www.elastic.co/guide/en/elasticsearch/reference/6.8/indices-templates.html
        base_template: # this is a custom name for the index template
            client: default
            template: "*" # this is where you define which indices will use this template
            types:
                _doc: # this is where you define which types will use this (_doc stands for every type/documents)
                    dynamic_templates: # https://www.elastic.co/guide/en/elasticsearch/reference/6.8/dynamic-templates.html
                        dynamic_date_template: # this is a custom name for the dynamic field template
                            match_pattern: regex
                            match: created|updated|tpq_date|taq_date
                            mapping:
                                type: date
                        dynamic_location_template:
                            match: location
                            mapping:
                                type: geo_point