elasticsearch using more_like_this with some constraints

48 Views Asked by At

I am using elasticsearch to detect duplicates in user names.

Here is a sample of code to get similar users which their names is close to john doe and their first name is the john

 "query" => [
                "bool" => [
                    "must" => [
                        [
                            "prefix" => [
                                "name.keyword" => [
                                    "value" => "john"
                                ]
                            ]
                        ],
                        [
                            "more_like_this" => [
                                "fields" => ["name"],
                                "minimum_should_match" => "100%",
                                "min_term_freq" => 1,
                                "max_query_terms" => 30,
                                "like" => "john doe",
                            ]
                        ]
                    ]
                ]
            ]

It should return users close to john doe and starts with john. But the response in this case contains names not started with john.

What is wrong with the code?

0

There are 0 best solutions below