https://blog.csdn.net/u011915540/article/details/102673883

https://zhuanlan.zhihu.com/p/344770083

https://www.elastic.co/guide/en/elasticsearch/reference/7.x/sort-search-results.html#_script_based_sorting

搜索时使用了其他字段作为排序条件, ES 默认是使用 _score 作为排序条件的

sort 里增加 _score 字段排序

GET bte/_search
  "explain": true, 
  "size": 10,
  "_source": [
    "sku_id",
    "goods_name",
    "is_show",
    "common_is_show",
    "alias_name",
    "sort_tag"
  "sort": [
      "_script": {
        "type": "number",
        "script": {
          "lang": "painless",
          "source": " doc['sort_tag'].value + _score * params.factor  ",
          "params": {
            "factor": 1.1
        "order": "desc"
       "_score":{
        "order": "desc"
  "query": {
    "bool": {
      "filter": [
          "terms": {
            "city_code": [
              304447,
              110100
          "term": {
            "is_show": 1
          "term": {
            "on_sale": 1
      "must": [
          "match": {
            "goods_name": {
              "query": "诺心"

elasticsearch 权重及排序

树上的花开了,人们心里的花也开了,涨不涨?涨。可是树上的花不开,人们心里的花可不可以开?可以。所以,股票价格不是客观事件的反映,是人们内心世界的反映。一样的,有一天树上的花终于开了,可是人们心里的花却在谢,是涨还是跌?跌!