简体   繁体   中英

Custom score in Elastic Search

I have an index, where each document represents a class, with list of students and a list of teachers.

Here is the mapping:

{
"properties" :  {
    "students" : {
        "include_in_root" : 1,
        "type" : "nested",
        "properties" : {
            "name" : {
                "first" : "text",
                "last" : "text",
                },
            },
            "email" : { "type" : "string", "index" : "not_analyzed" },
        },

    "teachers" : {
        "include_in_root" : 0,
        "include_in_all" : 0,
        "type" : "nested",
        "properties" : {
            "name" : {
                "title" : { "type" : "string", "index" : "not_analyzed" },
                "first" : "text",
                "last" : "text",
                },
            },
        },
    },
}

I would like to influence Elastic Search score function, such that it will give higher score to documents with matched techers .

For example, if I have search for "Smith", I would like the documents with teacher Smith be with higher score than documents with students Smith.

Does anyone knows how it should be done in Elastic Search? In other words, how can I return the results ordered by some logic?

Thanks in advance!

在这里回答: https ://groups.google.com/forum/?fromgroups#!search /%22使用$ 20a $ 20bool $ 20query $ 20to $ 20run $ 20two $ 20nested $ 20queries%22 / elasticsearch / XTAb7eHcbqI / UgnKDh7ou48J

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM