ksaa0096329
V2EX  ›  问与答

求助,问个 Elasticsearch 的问题

  •  
  •   ksaa0096329 · Nov 24, 2017 · 1825 views
    This topic created in 3153 days ago, the information mentioned may be changed or developed.

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

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

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

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   954 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 22:28 · PVG 06:28 · LAX 15:28 · JFK 18:28
    ♥ Do have faith in what you're doing.