Using More Like This
How do I pass in the parameters that make mlt useful (like mlt_fields and min_doc_freq)?
Hi Rick,
If you want to use the provided API method, you should pass the :data variable (which pass any structure you like as the structure body of the request).
For example:
Flex.more_like_this :type => 'the_type', :id => 'the_id', :data => {:fields => [:a, :b]}
If you have a lot of data to pass, then it might be probably better just write your own template (not a search-template though), eventually with some default, for example:
my_mlt:
- GET
- /<<index>>/<<type>>/<<id>>/_mlt
- fields: <<fields>>
min_term_freq: <<:min_term_freq= 1 >>,
max_query_terms: <<max_query_terms= 10 >>
The search template is the way to go if you want to use the more_like_this query instead of the API. For example:
my_query:
query:
bool:
must:
- query_string:
query: <<q= '*' >>
- more_like_this:
like_text: <<like_text= ~ >>
fields: <<like_fields= ~ >>
Notice that the :like_text and the like_fields in this example are optional, so when you don't pass them the more_like_this structure branch will be pruned.
HTH