さまざまなユーザーがトピックをフォローできる Rails アプリケーションがあります。名前に一致し、特定のユーザーがフォローしているトピックを検索できるようにしたいと考えています。. なしで Tirequery
ステートメントのみを使用しfilter
ます。
そのために、ネストされたクエリでブールクエリを使用するつもりです。
ここに私のトピックモデルがあります:
class Topic < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
mapping do
indexes :name
indexes :follower_ids, type: 'nested', as: "indexed_follower_ids", id: 'integer'
end
def indexed_follower_ids
followers.pluck(:id).map { |id| {id: id} }.to_json
end
attr_accessible :name
end
Follow モデルには以下が含まれます
after_save :update_topic_index
def update_topic_index
topic.tire.update_index
end
残念ながら、データベースにいくつかのレコードをシードした後、何もインデックス化されません。たとえば、次のレコードを作成するとします。
User.create! name: "user0"
Topic.create! name: "topic0"
Follow.create! user: User.first, topic: Topic.first
ElasticSearch サーバー ログに次のエラーが表示されます。
[2013-04-16 15:07:28,564][INFO ][cluster.metadata ] [Sligguth] [topics] creating index, cause [api], shards [5]/[1], mappings [topic]
[2013-04-16 15:07:28,690][DEBUG][action.index ] [Sligguth] [topics][2], node[UdT6jTecRNuzdRkxkX2uUA], [P], s[STARTED]: Failed to execute [index {[topics][topic][1], source[{"name":"topic0","follower_ids":"[]"}]}]
org.elasticsearch.index.mapper.MapperParsingException: object mapping for [topic] tried to parse as object, but got EOF, has a concrete value been provided to it?
at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:457)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:494)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:438)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:308)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:202)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
[2013-04-16 15:07:28,709][DEBUG][action.index ] [Sligguth] [topics][2], node[UdT6jTecRNuzdRkxkX2uUA], [P], s[STARTED]: Failed to execute [index {[topics][topic][1], source[{"name":"topic0","follower_ids":"[{\"key_id\":1}]"}]}]
org.elasticsearch.index.mapper.MapperParsingException: object mapping for [topic] tried to parse as object, but got EOF, has a concrete value been provided to it?
at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:457)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:494)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:438)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:308)
at org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:202)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
入れ子になった のインデックス作成で ElasticSearch が失敗する理由は何follower_ids
ですか?