0

Heroku/Bonsai でフィールドを使用しようとしていますgeo_pointが、うまくいきません。

ローカルで動作しますが、Heroku/Bonsai でインデックスのマッピングを確認すると、フィールドが文字列であると表示されます。"coordinates":{"type":"string"}

私のマッピングは次のようになります。

tire.mapping do
  ...
  indexes :coordinates, type: "geo_point", lat_lon: true
  ...
end

そして私のto_indexed_jsonような:

def to_indexed_json
  {
    ...
    coordinates: map_marker.nil? ? nil : [map_marker.latitude, map_marker.longitude].join(','),
    ...
  }.to_json
end

Heroku のコンソールで試しMyModel.mappingてみMyModel.index.mappingましたが、最初のコンソールには:coordinates=>{:type=>"geo_point", :lat_lon=>true}.

4

1 に答える 1

1

これが私がこれを機能させる方法です。インデックス名 ' myindex ' タイプ名 ' myindextype '

ローカル マシン上

curl -XGET https://[LOCAL_ES_URL]/myindex/myindextype/_mapping

出力を .json ファイルに保存します。例: typedefinition.json (または手動ビルド)

{
  "myindextype":{
    "properties":{
      "dataone":{"type":"string"},
      "datatwo":{"type":"double"},
      "location":{"type":"geo_point"},
      "datathree":{"type":"long"},
      "datafour":{"type":"string"}
    }
  }
}

herokuでコマンドを入力します

heroku config

BONSAI_URL を取得します。以下のコマンドの[BONSAI_URL]の代わりに入れます。( https://asdfasdfdsf:asdfadf@asdfasdfasdf.us-east-1.bonsai.io/myindex )

curl -XDELETE https://[BONSAI_URL]/myindex
curl -XPOST https://[BONSAI_URL]/myindex
curl -XPUT -d@typedefinition.json https://[BONSAI_URL]/myindex/myindextype/_mapping 
curl -XGET https://[BONSAI_URL]/myindex/myindextype/_mapping
  1. インデックスが存在する場合は削除します。
  2. 空のインデックスを作成します。
  3. .json ファイルをマッピングの定義として使用します。
  4. 新しいマッピングを取得して、それが機能していることを確認します。
于 2013-08-16T19:01:51.390 に答える