2014-09-16 7 views
5

Я уже сделал Comment.import, и он вернул 0, что означает, что во время процесса импорта не было ошибок.elasticsearch-rails empty results

Я уже сделал Comment.__elasticsearch__.refresh_index!

Это модель я использую:

require "datamapper_adapter" 

class Comment 
    include DataMapper::Resource 

    include Elasticsearch::Model 

    property :id, Serial 
    property :email, String 
    property :author, String 
    property :description, String 
    property :created_at, DateTime 

    belongs_to :picture 

    validates_presence_of :email, :author, :description 

    settings index: { number_of_shards: 1 } do 
    mappings dynamic: 'false' do 
     indexes :id, analyzer: 'english', index_options: 'offsets' 
     indexes :author, analyzer: 'english', index_options: 'offsets' 
     indexes :description, analyzer: 'english', index_options: 'offsets' 
    end 
    end 

    def as_indexed_json(options={}) 
    as_json.except("picture_id", "created_at", "email", "_persistence_state", "_repository", "_id") 
    end 
end 

И еще все мои запросы к elasticsearch возвращает пустой массив как хиты.

curl -XPOST 'http://localhost:9200/comments/comment/_search?pretty 
{ 
    "took" : 35, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 5, 
    "successful" : 5, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 0, 
    "max_score" : null, 
    "hits" : [ ] 
    } 
} 

У меня есть данные в моей БД, но я понятия не имею, почему он никогда не фильтруется. Любые идеи, почему это происходит? Это сводит меня с орехами

не

Независимо от того, что я делаю, ударяется ВСЕГДА пусто

+0

У меня такая же проблема .. Вы решили? – JonatasTeixeira

+0

Есть ли шанс увеличить уровень DEBUG, чтобы получить больше информации о том, что происходит во время импорта? – Val

+0

Загрузите главу elasticsearch (http://mobz.github.io/elasticsearch-head/) и подключитесь к вашему экземпляру ES. Он содержит данные, которые вы ожидаете? – Codebeef

ответ

1

вы могли бы попытаться добавить type:string к indexes :description и indexes :author

я помню, у меня была проблема с as_json, для старых рельсов версии будут включать атрибут root. Попробуйте установить значение false, вы можете сделать это глобально или в as_json(root: false)