I am using the search API and now you need to add a completion assistant , I am using elasticsearch-rails stone.
When I search for an article, everything works http: // localhost: 9200 / articles / _search
"query": { "multi_match": { "query": "test", "fields": [ "title", "tags", "content" ] } } }
But since I implemented the completion assistant, I had to edit as_indexed_json to work, but now the search API no longer works, only suggestions.
Here is my article model:
def self.search(query) __elasticsearch__.search( { query: { multi_match: { query: query, fields: ['title', 'content', 'tags'] } } }) end def self.suggest(query) Article.__elasticsearch__.client.suggest(:index => Article.index_name, :body => { :suggestions => { :text => query, :completion => { :field => 'suggest' } } }) end def as_indexed_json(options={}) { :name => self.title, :suggest => { :input => self.title, :output => self.title, :payload => { :content => self.content, :tags => self.tags, :title => self.title } } }.as_json end
Is it possible that _search and _suggest work together with the same model?
source share