V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
longkas239
V2EX  ›  Elasticsearch

文本匹配不如预期,怎么回事呀

  •  
  •   longkas239 · 161 天前 · 689 次点击
    这是一个创建于 161 天前的主题,其中的信息可能已经有所发展或是发生改变。

    用 match query 查询字符串"the lord",结果返回

    score=8.081023 "The Second Sun" score=5.412263 "Lord of War" score=4.5157876 "The Lord of the Rings: The Two Towers" score=4.120181 "The Lord of the Rings: The Fellowship of the Ring" score=4.120181 "The Lord of the Rings: The Return of the King"

    模糊参数改一下,结果也是一样的。刚接触 Elasticsearch,这排序是正常的吗, "The Second Sun" 评分怎么那么高

    4 条回复    2021-05-13 06:43:21 +08:00
    littlehappi
        1
    littlehappi   161 天前
    用 match_phrase 试试
    skyleft
        2
    skyleft   161 天前
    按你这个搜出来的应该是这样吧

    "hits" : [
    {
    "_index" : "test",
    "_type" : "1",
    "_id" : "6NVkW3kBGtH1h4VDFSRZ",
    "_score" : 0.86009264,
    "_source" : {
    "title" : "The Lord of the Rings: The Two Towers"
    }
    },
    {
    "_index" : "test",
    "_type" : "1",
    "_id" : "6dVkW3kBGtH1h4VDVCSG",
    "_score" : 0.8239962,
    "_source" : {
    "title" : "The Lord of the Rings: The Fellowship of the Ring"
    }
    },
    {
    "_index" : "test",
    "_type" : "1",
    "_id" : "59VjW3kBGtH1h4VD1iSf",
    "_score" : 0.65877354,
    "_source" : {
    "title" : "Lord of War"
    }
    },
    {
    "_index" : "test",
    "_type" : "1",
    "_id" : "5NViW3kBGtH1h4VD3SQA",
    "_score" : 0.35161144,
    "_source" : {
    "title" : "The Second Sun"
    }
    }
    longkas239
        3
    longkas239   160 天前
    @skyleft 你用的是 match_phrase 类型吗
    skyleft
        4
    skyleft   160 天前
    @longkas239 match
    关于   ·   帮助文档   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   3997 人在线   最高记录 5497   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 06:34 · PVG 14:34 · LAX 23:34 · JFK 02:34
    ♥ Do have faith in what you're doing.