1
我使用的是elasticsearch
和php
,我想用Geo Distance Query進行搜索,但是在閱讀google上的一些文章之後,我必須在當前索引代碼中添加geo location
,但不知道如何加。如何在elasticsearch索引中添加地理位置
$indexed = $client->index([
'index' => 'users',
'type' => 'user',
'body' => [
'name' => $name,
'email' => $email,
'company' => $company,
'phone' => $phone,
'streetAddress' => $streetAddress,
'route' => $route,
'city' => $locality,
'state' => $state,
'postalCode' => $postalCode,
'country' => $country,
'latitude' => $latitude,
'longitude' => $longitude,
'content' => $content,
'date' => strtotime(date('Y-m-d H:i:s'))
]
]);
我指的是這個Geo Location and Search文章,但沒有得到任何想法如何實現和使用的搜索查詢。
有什麼想法?
謝謝。
能否請你指導我,我要加' 「屬性」:{ 「位置」:{ 「類型」: 「geo_point」 } }'這個? –
在你的文檔的映射中,你可以通過發送post請求到'_mapping/user'手動完成。如果你看一下映射文檔 –
我還沒有關於映射的想法,但我有這個搜索代碼:'$ query = $ client-> search'[ 'body'=> [ 'sort'=>'date'=> ['order'=>'desc'] ], 'query' => [ '布爾'=> [ '應當'=> [ '匹配'=> [$濾波器=> $ q] ] ] ] ] ]);' –