es7 10-10 java搜索接入

低价排序模型
只影响召回 不影响排序 使用replace 

# 低价排序
GET shop/_search
{
  "_source": "*",
  "script_fields": {
    "distance": {
      "script": {
        "source": "haversin(lat,lon,doc['location'].lat,doc['location'].lon)",
        "lang":"expression",
        "params": {"lat":31.23916171,"lon":121.48780049}
      }
    }
  },
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "name": {"query": "凯悦","boost": 0.1}
              }
            },{
              "term": 
               { "seller_disabled_flag": 0} // 表明商家没有被禁用
              },{
                "term": {
                  "category_id": {
                    "value": "2"
                  }
                }
              }
          ]
        }
      },
      "functions": [ // 定义排序规则
        {
          "field_value_factor": { // 商家的评分以5分为归一化
            "field": "price_per_man"
          },
          "weight": 1
        }
      ],
      "score_mode": "sum",
      "boost_mode": "replace"  // 和对应的query 的打分规则  sum改为replace 文本相关性不考虑 基于距离和评分
    }
  }
  , "sort": [
    {
      "_score": {
        "order": "desc"
      }
    }
  ]
}

标签 “落地窗” 无法查询

GET shop/_search
{
  "_source": "*",
  "script_fields": {
    "distance": {
      "script": {
        "source": "haversin(lat,lon,doc['location'].lat,doc['location'].lon)",
        "lang":"expression",
        "params": {"lat":31.23916171,"lon":121.48780049}
      }
    }
  },
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "name": {"query": "凯悦","boost": 0.1}
              }
            },{
              "term": 
               { "seller_disabled_flag": 0} // 表明商家没有被禁用
              },{
                "term": {
                  "tags": {
                    "value": "落地大窗"
                  }
                }
              }
          ]
        }
      },
      "functions": [ // 定义排序规则
        {
          "gauss": { // 高斯衰减函数打分
            "location": {
              "origin": "31.23916171,121.48780049",
              "scale": "100km",
              "offset": "0km", // 起始点
               "decay": 0.5
            }
          },
          "weight": 9 // 相对于评分 距离是主要因素
        },{
          "field_value_factor": {
            "field": "remark_score" // 评分
          },
          "weight": 0.2
        }
        ,{
          "field_value_factor": { // 商家的评分以5分为归一化
            "field": "seller_remark_score"
          },
          "weight": 0.1
        }
      ],
      "score_mode": "sum",
      "boost_mode": "replace"  // 和对应的query 的打分规则  sum改为replace 文本相关性不考虑 基于距离和评分
    }
  }
  , "sort": [
    {
      "_score": {
        "order": "desc"
      }
    }
  ],
  "aggs": {
    "group_by_tags": {
      "terms": {
        "field": "tags"
      }
    }
  }
}

 es7 10-10 java搜索接入_第1张图片

tags 带fielddata 是可以被aggrate的 

你可能感兴趣的:(es7千人前面)