PHP和ElasticSearch 6.7-双精度被解析为字符串
我有一个ElasticSearch 6.7索引,其映射类似于:PHP和ElasticSearch 6.7-双精度被解析为字符串,php,
elasticsearch,Php,
elasticsearch,我有一个ElasticSearch 6.7索引,其映射类似于: { "mapping": { "doc": { "properties": { "brand": { "type": "double" }, "time_count": { "type": "integer" },
{
"mapping": {
"doc": {
"properties": {
"brand": {
"type": "double"
},
"time_count": {
"type": "integer"
},
"total_cost": {
"type": "double"
},
...
}
}
当我使用官方PHP为一些文档编制索引时,索引是成功的,但我所有的双精度/整数数据点都被解析为字符串,我无法使用任何数字聚合或搜索词
我尝试过在索引时强制使用PHP中的类型,但这并不能解决问题
$index = [
'brand' => (string) $brand,
'time_count' => (double) $t->rate_bill_min,
'total_cost' => (double) $t->vendor_bill_min
...
];
$up = [
'body' => $payload,
'index' => 'termination_metrics',
];
$r = $client->index($up);
当我的数据被编入索引时,为了保持数据的双精度/整数状态,我必须做些什么?它们实际上是作为字符串存储在Elasticsearch中,还是仅仅作为字符串返回?许多DB驱动程序将浮点作为字符串值返回,以避免浮点错误。出于同样的原因,你也不应该把钱作为浮动货币存放在任何地方。在Elasticsearch中,实际上只有一个整数和一个除数,相当于大多数RDBMS中的
DECIMAL
类型。@Sammitch Kibana将它们列为字符串。如果映射为真,我想这将表明它们是以这种方式存储的。这是正确的想法吗?