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

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

  •  
  •   longkas239 · 2021-05-11 15:03:36 +08:00 · 1674 次点击
    这是一个创建于 1317 天前的主题,其中的信息可能已经有所发展或是发生改变。

    用 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  
       2021-05-11 16:05:57 +08:00
    用 match_phrase 试试
    skyleft
        2
    skyleft  
       2021-05-12 10:12:57 +08:00
    按你这个搜出来的应该是这样吧

    "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  
    OP
       2021-05-12 19:56:06 +08:00
    @skyleft 你用的是 match_phrase 类型吗
    skyleft
        4
    skyleft  
       2021-05-13 06:43:21 +08:00
    @longkas239 match
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1020 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:56 · PVG 03:56 · LAX 11:56 · JFK 14:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.