Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Using More Like This #8

Open
rickthomasjr opened this issue Oct 21, 2013 · 1 comment
Open

Using More Like This #8

rickthomasjr opened this issue Oct 21, 2013 · 1 comment

Comments

@rickthomasjr
Copy link

How do I pass in the parameters that make mlt useful (like mlt_fields and min_doc_freq)?

@ddnexus
Copy link
Owner

ddnexus commented Oct 21, 2013

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants