0
votes

If I have a table, which contains a lot of persons. Each person will have their own attributes such as name, social id, age, sex, number of children...

Given a person A which is 40 years old male, have 2 children.. Provide me all persons that is similar to person A.

Is this something I can do with Elastic search? I'm thinking about More Like This query https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html

Thank you very much.

1
what do you mean with "similar" in this case? Maybe More Like This query does not fit to you as it operates on textIgor Belo
So in case I put everything in a text string , e.g. "Person B, a 49 years old male, born on a summer day, has 2 children, 1 boy and 1 girl" , "Person B, a 49 years old female, born on a winter day, has 1 children, 1 boy and 0 girl". Will elasticSearch's Maybe More Like be able to work on something like this ? Thank you :)Xitrum
Yes and no. MLT will find documents with "similar" text strings. But what "similar" means (more or less), is "having the most terms in common". You'll have filter yourself to ensure that your own definition of numeric similarity (e.g. for age, social id, and number of children) is upheld. Otherwise, your most similar person could be "Person C, a 79 years old female, born on a winter day has 23 children, 1 boy and 22 girl" (as it's only different by 4 terms: ["C", "79", "23", "22"])Peter Dixon-Moses

1 Answers

0
votes

Yes MLT will work properly, you can specify the fields where you want to apply the more like this query, like for in your case, it would be age, number of children. Any other specific field through which you want to match. Here is the exmaple query-

GET /_search
{
    "query": {
        "more_like_this" : {
            "fields" : ["age", "number_of_children"],
            "like" : 
            {
                "_index" : "people",
                "_type" : "person",
                "_id" : "1"
            },
            "min_term_freq" : 1
        }
    }
}