Q:

How do I use More Like This API in Elasticsearch for ruby

I couldn't find any documentation about this at all. Or, maybe I'm missing something. I'm trying to use Elasticsearch's More Like This API with the elasticsearch gem.
I've indexed all documents already.
Here's my code:
require 'elasticsearch'

client = Elasticsearch::Client.new log: true

client.search index: 'movies', body: { query: { match: { description: 'test' } } }

client.search index: 'movies', body: { more_like_this: {
  fields: ['description'],
  like_text: 'Once upon a time' 
} }  

I'm getting this error:

Parse Failure [No parser for element [more_like_this]]];
  }{[2fk_R7WbTky6UfMCbKPKGA][movies][1]

A:

Try wrapping your more_like_this in query, like so:
client.search index: 'movies', body: {
  query: { 
    more_like_this: {
      fields: ['description'],
      like_text: 'Once upon a time' 
    } 
  } 
}

Hope this helps!

