Question

This query works great, but it's returning too many results. I would like to add the boost function but I don't know the proper syntax.

$data_string = '{
"from" : 0, "size" : 100,
"sort" : [
    { "date" : {"order" : "desc"} }
],
"query": {
        "more_like_this_field" : {
            "thread.title" : {
                "like_text" : "this is a test",
                "min_word_len" : 4,
                "min_term_freq" : 1,
                "min_doc_freq" : 1
            }
        }
    }
}';

No correct solution

OTHER TIPS

Found the solution. Looks like using fuzzy_like_this_field and min_similarity is the way to go.

$data_string = '{
"from" : 0, "size" : 100,
"query": {
        "fuzzy_like_this_field" : {
            "thread.title" : {
                "like_text" : "this is a test",
                "min_similarity": 0.9
            }
        }
    }
}';

According to the docs, you just need to add it to the other parameters:

...
"thread.title" : {
    "like_text" : "this is a test",
    "min_word_len" : 4,
    "min_term_freq" : 1,
    "min_doc_freq" : 1,
    "boost": 1.0
}
...

Also, if you have too many docs, you can try to increase the min_term_freq and the min_doc_freq, too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top