古い自作の検索エンジンの代わりに、ElasticSearch の実装を開始します。コードの大部分を移行しましたが、ペーパークリップによって提供された URL をレンダリングする必要があり、結果に正しいオブジェクトを含めることができません
has_attached_file :content、url: '/system/:attachment/:id/:style/:filename'
mapping do
indexes :name
indexes :description
indexes :tags do
indexes :name, type: :string
end
indexes :content, type: :object do
indexes :url
end
end
def to_indexed_json
{
name: name,
description: description,
tags: tags.map { |tag| { name: tag.name }},
content: content_url_json
}.to_json
end
そして、ここにcurlでElasticsearchをクエリしたときの結果があります
{
"element": {
"properties": {
"content": {
"type": "string"
},
"name": {
"type": "string"
},
"tags": {
"properties": {
"name": {
"type": "string"
}
}
}
}
}
}
電話する必要がありますelement.content.url
。しかしcontent
、オブジェクトに目を向けることができないため、この呼び出しは失敗します。私のコードで何が間違っているかを見つける方法を見つけるのを手伝ってくれませんか?