国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 操作系統 > 正文

Elasticsearch學習筆記:multi-fields

2024-06-28 16:01:49
字體:
來源:轉載
供稿:網友

multi-fields

It is often useful to index the same field in different ways for different purposes. This is the purpose of multi-fields. For instance, a string field could be mapped as a text field for full-text search, and as a keyWord field for sorting or aggregations. You can define as many fields with the fields parameter as you want. Please note that this option is only available for core data types and not for the objects.

對一個field設置多種索引方式。比如,一個字符串設置為”text”類型用于進行全文檢索,同時又給它設置”keyword”類型用于排序或聚合。

#對需要設置的字段,在'type'屬性后增加"fields": #其中的"raw"為自定義的名稱,想象它是city的一個分身。PUT /my_index{ "mappings": { "my_type": { "PRoperties": { "city": { "type": "text", "fields": { "raw": { "type": "keyword" } } } } } }}

插入數據

PUT /my_index/my_type/1{ "city": "New York"}PUT /my_index/my_type/2{ "city": "York"}

查詢并排序 查詢字段為city,使用它的text類型.排序使用了city.raw

GET /my_index/_search{ "query": { "match": { "city": "York" } }, "sort": { "city.raw": "asc" }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 全南县| 新宾| 普陀区| 武定县| 武平县| 嘉善县| 藁城市| 大埔县| 武邑县| 漾濞| 马山县| 石景山区| 静安区| 大安市| 宣威市| 天津市| 普格县| 达孜县| 静乐县| 通化县| 广河县| 德保县| 舟曲县| 无棣县| 深泽县| 微山县| 华宁县| 永善县| 科技| 孟州市| 临桂县| 石首市| 水富县| 通山县| 抚松县| 玛多县| 临泉县| 会泽县| 山丹县| 沁阳市| 临清市|