def wechat_query(q)
Rails.logger.info("========= #{q}")
search_modules = [Topic]
search_params = {
query: {
simple_query_string: {
query: q,
default_operator: 'OR',
minimum_should_match: '60%',
fields: %w(title body name tags)
}
},
highlight: {
pre_tags: ['[h]'],
post_tags: ['[/h]'],
fields: { title: {}, body: {}, name: {}, tags: {} }
}
}
Elasticsearch::Model.search(search_params, search_modules)
end
def user_interest_query(query)
items = []
query.split(',').each do |q|
qs = wechat_query(q).records
items = items | qs
end
items
end
当调用 user_interest_query(query) 出现 出现的问题如下: Transport::Transport::Errors::NotFound: [404] {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"topics","index_uuid":"na","index":"topics"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"topics","index_uuid":"na","index":"topics"},"status":404}