简体   繁体   English

Elastic Search中的自定义分数

[英]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 . 我想影响Elastic Search的评分功能,这样它将为具有匹配技术人员的文档提供更高的评分。

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. 例如,如果我搜索“ 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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