Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch 基于整数值的Boost评分-Elasticsearch_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Boost_Filter - Fatal编程技术网 elasticsearch 基于整数值的Boost评分-Elasticsearch,elasticsearch,boost,filter,elasticsearch,Boost,Filter" /> elasticsearch 基于整数值的Boost评分-Elasticsearch,elasticsearch,boost,filter,elasticsearch,Boost,Filter" />

elasticsearch 基于整数值的Boost评分-Elasticsearch

elasticsearch 基于整数值的Boost评分-Elasticsearch,elasticsearch,boost,filter,elasticsearch,Boost,Filter,我对ElasticSearch不是很有经验,我想知道如何基于某个整数值提升搜索 这是一个文档示例: { "_index": "links", "_type": "db1", "_id": "mV32vWcBZsblNn1WqTcN", "_score": 8.115617, "_source": { "url": "example.com", "title": "Example website", "desc

我对ElasticSearch不是很有经验,我想知道如何基于某个整数值提升搜索

这是一个文档示例:

{
    "_index": "links",
    "_type": "db1",
    "_id": "mV32vWcBZsblNn1WqTcN",
    "_score": 8.115617,
    "_source": {
        "url": "example.com",
        "title": "Example website",
        "description": "This is an example website, used for various of examples around the world",
        "likes": 9,
        "popularity": 543,
        "tags": [
            {
                "name": "example",
                "votes": 5
            },
            {
                "name": "test",
                "votes": 2
            },
            {
                "name": "testing",
                "votes": 1
            }
        ]
    }
}
现在在这个特定的搜索中,重点是
标记
,我想知道如何提高
\u分数
,并将其乘以
标记
投票
中的整数

如果这不可能(或很难实现),我只想知道如何通过投票提高
\u分数
(不在
标签下

例如,将投票中的每个整数的
\u分数
加上0.1

这是我正在使用的当前搜索查询(仅用于搜索标签):


我在网上找不到什么,希望有人能帮我

如何使用整数值提升
\u分数


更新 有关详细信息,请参见以下映射:

{
    "links": {
        "mappings": {
            "db1": {
                "properties": {
                    "url": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "title": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "description": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "likes": {
                        "type": "long"
                    },
                    "popularity": {
                        "type": "long"
                    },
                    "tags": {
                        "type": "nested",
                        "properties": {
                            "name": {
                                "type": "text",
                                "fields": {
                                    "keyword": {
                                        "type": "keyword",
                                        "ignore_above": 256
                                    }
                                }
                            },
                            "votes": {
                                "type": "long"
                            }
                        }
                    }
                }
            }
        }
    }
}
更新2
标记.喜欢的
/
标记.不喜欢的
更改为
标记.投票
,并将
嵌套的
属性添加到您正在查看的
功能评分查询

字段值因子

文档中的片段:

GET /_search
{
    "query": {
        "function_score": {
            "field_value_factor": {
                "field": "tags.dislikes",
                "factor": 1.2,
                "modifier": "sqrt",
                "missing": 1
            }
        }
    }
}

或者使用
脚本得分
,因为嵌套的
标记
字段(不确定
字段值得分
是否适用于嵌套结构)。

这需要很长时间才能解决。我在去那里的路上学到了很多东西

以下是最终结果:

{
    "query": {
        "nested": {
            "path": "tags",
            "query": {
                "function_score": {
                    "query": {
                        "bool": {
                            "should": [
                                {
                                    "match": {
                                        "tags.name": "example"
                                    }
                                },
                                {
                                    "match": {
                                        "tags.name": "testing"
                                    }
                                },
                                {
                                    "match": {
                                        "tags.name": "test"
                                    }
                                }
                            ]
                        }
                    },
                    "functions": [
                        {
                            "field_value_factor": {
                                "field": "tags.votes"
                            }
                        }
                    ],
                    "boost_mode": "multiply"
                }
            }
        }
    }
}

should
中的数组帮了大忙,我很高兴能将它与
function\u score

结合起来,你能显示你的映射吗?
标签是否为
嵌套的
类型?@Val I更新了问题,并添加了映射。我不知道这是否是嵌套的。谢谢,问题是如果你想达到你期望的效果,
标记
应该嵌套,否则你不能查询特定的嵌套标记以获得它们的喜欢/不喜欢值来提高分数。@Val我希望是这样的。但是通过嵌套标签,这是否意味着我不能设置自定义/新的“名称”?地图需要很大才能覆盖世界上所有的标签吗?或者我只需要改变一下映射?我正在考虑创建一个db2,并慢慢地将所有文档迁移到一个新的映射结构。请参见:
{
    "query": {
        "nested": {
            "path": "tags",
            "query": {
                "function_score": {
                    "query": {
                        "bool": {
                            "should": [
                                {
                                    "match": {
                                        "tags.name": "example"
                                    }
                                },
                                {
                                    "match": {
                                        "tags.name": "testing"
                                    }
                                },
                                {
                                    "match": {
                                        "tags.name": "test"
                                    }
                                }
                            ]
                        }
                    },
                    "functions": [
                        {
                            "field_value_factor": {
                                "field": "tags.votes"
                            }
                        }
                    ],
                    "boost_mode": "multiply"
                }
            }
        }
    }
}