简体   繁体   English

Elasticsearch字段值因子具有多重匹配?

[英]Elasticsearch field value factor with multi matching?

I'm using this to search my outfits: 我正在用它来搜索我的服装:

def self.search(query, purchasedlow, purchasedhigh)
__elasticsearch__.search(
{
  query: {
    function_score: {
      query: {
        bool: {
          filter: [
            {
              multi_match: {
                query: query,
                fields: ['name','description','material']
              }
            },
            {
              range: {
                purchased: { lte: purchasedhigh.to_i, gte: purchasedlow.to_i},
              },          
            }
          ]
        }
      }
    }
  }
}
)
end

But I don't know how to add this code: 但是我不知道如何添加以下代码:

    field_value_factor: {
      field: "likes",
      factor: "100"
    }

I know that I'm supposed to put it after the function score, so that the calculated score is then multiplied by the amount of likes to make the final score, but when I put the code after the function_score, I get the following error: 我知道我应该将其放在函数分数之后,以便将计算出的分数乘以喜欢的数量即可得出最终分数,但是当我将代码放在function_score之后时,出现以下错误:

[400] {"error":{"root_cause":[{"type":"parsing_exception","reason":"[function_score] malformed query, expected [END_OBJECT] but found [FIELD_NAME]","line":1,"col":232}],"type":"parsing_exception","reason":"[function_score] malformed query, expected [END_OBJECT] but found [FIELD_NAME]","line":1,"col":232},"status":400}

Where do I need to put the field value factor so that it works correctly? 我需要将字段值因子放在哪里才能使其正常工作?

I used field_value_factor in one of my queries like this: 我在以下查询之一中使用了field_value_factor:

@products = Product.search(
 query:{
   function_score:{
     query:{
       bool:{
         must:{
           multi_match:{
             fields: ['brand^5', '_all'],
             query: "#{query}",
             fuzziness: "AUTO"
           }
         },

           filter:{
             bool:{
               must:[
                 {term: {"brand":"NordicTrack"}},
                 {term: {"product_type":"Treadmill"}}
               ]
             }
           }

       }
     },
     field_value_factor:{
        field: "popularity",
        modifier: "log1p"
     }
   }
 })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM