V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
ksaa0096329
V2EX  ›  问与答

求助,问个 Elasticsearch 的问题

  •  
  •   ksaa0096329 · 2017-11-24 16:06:52 +08:00 · 1138 次点击
    这是一个创建于 2316 天前的主题,其中的信息可能已经有所发展或是发生改变。

    这样一个需求,搜索产品,关键字在字段 name 和 description 上,name 匹配度高于 desc。我写的是这样的

    query: {
            bool: {
              should: [
                {
                  match: {
                    name: {
                      query: input,
                      boost: 2
                    }
                  }
                },
                {
                  match: {
                    description: {
                      query: input,
                      boost: 1
                    }
                  }
                }
              ]
            }
          }
    

    这样搜索对不对,es 能不能同时对两个字段模糊搜索,它是不是只能搜索词,新手,求助。

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5408 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 06:49 · PVG 14:49 · LAX 23:49 · JFK 02:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.