首页 新闻 会员 周边 捐助

ES 文本类型的数据排序是按照什么样儿的顺序

0
悬赏园豆:10 [已解决问题] 解决于 2021-04-23 10:09

这是排序的es语句

{
  "from": 0,
  "size": 10,
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "databaseCode.comma": {
              "query": "article_news",
              "operator": "OR",
              "prefix_length": 0,
              "max_expansions": 50,
              "fuzzy_transpositions": true,
              "lenient": false,
              "zero_terms_query": "NONE",
              "auto_generate_synonyms_phrase_query": true,
              "boost": 1
            }
          }
        },
        {
          "bool": {
            "adjust_pure_negative": true,
            "boost": 1
          }
        }
      ],
      "adjust_pure_negative": true,
      "boost": 1
    }
  },
  "_source": {
    "includes": [],
    "excludes": [
      "@timestamp",
      "@version",
      "CreateDate",
      "ExportDate"
    ]
  },
  "sort": [
    {
      "标题.keyword": {
        "order": "desc"
      }
    }
  ],
  "highlight": {
    "pre_tags": [
      "<span style='color:red'>"
    ],
    "post_tags": [
      "</span>"
    ],
    "fields": {
      "databaseCode": {},
      "databaseCode.comma": {}
    }
  }
}

这是返回结果
第一页

第二页

???????????????????????????????????????????
文本类型,尤其是首字为汉字的,这是什么蜜汁排序?
???????????????????????????????????????????

这个mapping

{
    "article_all": {
        "mappings": {
            "article_all": {
                "properties": {
                    "@timestamp": {
                        "type": "date"
                    },
                    "@version": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "CreateDate": {
                        "type": "date"
                    },
                    "ExportDate": {
                        "type": "date"
                    },
                    "YEAR": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "abstrat": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "area": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "author": {
                        "type": "text",
                        "fields": {
                            "comma": {
                                "type": "text",
                                "analyzer": "comma_analyzer",
                                "fielddata": true
                            },
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "category_id": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "content": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "databaseCode": {
                        "type": "text",
                        "fields": {
                            "comma": {
                                "type": "text",
                                "analyzer": "comma_analyzer",
                                "fielddata": true
                            },
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "datafrom": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "datasysid": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "file_path": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "format": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "id": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "is_lock": {
                        "type": "integer"
                    },
                    "key_word": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "month": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "publish_time": {
                        "type": "date"
                    },
                    "sort_id": {
                        "type": "integer"
                    },
                    "source_database": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "source_id": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "sys_fld_browserate": {
                        "type": "integer"
                    },
                    "sys_fld_downloadrate": {
                        "type": "integer"
                    },
                    "title": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "type": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "unit": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    },
                    "year": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            },
                            "suggest": {
                                "type": "completion",
                                "analyzer": "pinyin_prefix_analyzer",
                                "search_analyzer": "keyword",
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        },
                        "analyzer": "pinyin_analyzer",
                        "search_analyzer": "ik_max_word"
                    }
                }
            }
        }
    }
}
代码羡的主页 代码羡 | 初学一级 | 园豆:69
提问于:2021-03-17 14:11
< >
分享
最佳答案
0

按照字符串的ASCII进行排序

代码羡 | 初学一级 |园豆:69 | 2021-03-17 14:31
其他回答(2)
0

你用es做搜索,查出来的结果肯定都是相关的,他有一个算法,会根据相关性打分,打分高的,排最前面

收获园豆:3
不知道风往哪儿吹 | 园豆:2037 (老鸟四级) | 2021-03-18 10:15

如果一样呢

支持(0) 反对(0) With_Her | 园豆:200 (初学一级) | 2022-06-09 14:33
0

不知道你能不能看的进去。。。

有个社区分享大神一直在写相关的东西,你可以看下这个文章。
https://blog.csdn.net/UbuntuTouch/article/details/104132454?

收获园豆:7
WMG-Eight | 园豆:973 (小虾三级) | 2021-03-29 15:21
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册