首页 > 解决方案 > laravel 中的 Elasticsearch geo_point 映射

问题描述

我正在尝试将我的位置映射为“geo_point”。我使用 mysql DB 将点类型数据存储为“位置”。这是我的模型-'GeoSearch'的代码。

`protected $mapping = [
    'properties' => [
        'id' => [
            'type' => 'integer',
            'index' => 'not_analyzed'
        ],
        'Address' => [
            'type' => 'string',
            'analyzer' => 'english'
        ],
        'city' => [
            'type' => 'string',
            'analyzer' => 'english'
        ],
        'area' => [
            'type' => 'string',
            'analyzer' => 'english'
        ],
        'location' => [
            'type' => 'geo_point',
            'ignore_malformed' => true
        ],
    ]
];` 

但是,当我尝试使用 scout 进行索引时php artisan scout:import "App\GeoSearch",会显示以下错误。

"type":"illegal_argument_exception","reason":"mapp er [location] of different type, current_type [text], merged_type [geo_poin t]"}]

这是我的数据示例。由于“位置”存储为空间数据类型“点”,因此它以字节串形式显示。
{ "id": 32817, "longitude": "90.36189739", "latitude": "23.80241151", "Address": "abc", "city": "X", "area": "Y", "location": "0x000000000101000000B2A3AB53299756404C6239D76ACD3740", }

提前致谢 :)

标签: laravelelasticsearchmappinggeopoints

解决方案


推荐阅读