elasticsearch-rails
elasticsearch-rails copied to clipboard
NoMethodError: undefined method `find' for nil:NilClass
In production, we can't search in multiple models. it works fine locally.
Elasticsearch version v7.4.2
search_payload = {
query: {
bool: {
must: [
{
multi_match: {
query: params[:search].to_s.downcase
}
}
],
must_not: {
exists: {
field: 'deleted_at'
}
},
filter: [
{
term: {
user_: user_shop.id,
}
}
]
}
},
size: 7
}
records = Elasticsearch::Model.search(search_payload, [Order, Product]).records
records.json
NoMethodError: undefined method `find' for nil:NilClass
from /usr/local/bundle/gems/elasticsearch-model-7.0.0/lib/elasticsearch/model/adapters/multiple.rb:79:in `__records_for_klass'
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@Sexual Did you find solution?
@meoooh If this is still an issue for you, what version of the gem and stack are you using? I'll take a look as soon as it's possible.
@picandocodigo
elasticsearch (7.10.1)
elasticsearch-api (= 7.10.1)
elasticsearch-transport (= 7.10.1)
elasticsearch-api (7.10.1)
multi_json
elasticsearch-model (7.1.1)
activesupport (> 3)
elasticsearch (> 1)
hashie
elasticsearch-rails (7.1.1)
elasticsearch-transport (7.10.1)
faraday (~> 1)
multi_json
I am also running into this bug. I tracked it down to a failure to match __type_for_hit in vendor/bundle/gems/elasticsearch-model-7.1.1/lib/elasticsearch/model/adapters/multiple.rb:109
In our case we use index aliases so model.index_name == hit[:_index] will never be true. Also seems like with ElasticSearch deprecating the _type and document_type fields this will need to be reworked before ES 8 support is added.