国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【Elasticsearch學(xué)習(xí)筆記二】es的Mapping字段映射、Mapping字段常用類型、Mapping映射的創(chuàng)建、查看和更新、es數(shù)據(jù)遷移、ik分詞器

這篇具有很好參考價(jià)值的文章主要介紹了【Elasticsearch學(xué)習(xí)筆記二】es的Mapping字段映射、Mapping字段常用類型、Mapping映射的創(chuàng)建、查看和更新、es數(shù)據(jù)遷移、ik分詞器。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

目錄

1、Mapping字段映射概述

2、Mapping字段常用類型

3、映射中對(duì)時(shí)間類型詳解

1)采取自動(dòng)映射器來映射

2)手工映射提前指定日期類型

4、ES的keyword的屬性ignore_above

5、Mapping映射的查看和創(chuàng)建

1)查看mapping信息:GET 索引名/_mapping

2)創(chuàng)建映射:PUT /索引名

3)?查看所有索引映射關(guān)系

4)修改索引映射關(guān)系

5)一次性創(chuàng)建索引和映射

6、數(shù)據(jù)遷移-reindex

7、ik_max_word、ik_smart分詞器


1、Mapping字段映射概述

????????映射(Mapping)相當(dāng)于數(shù)據(jù)表的表結(jié)構(gòu)。ElasticSearch中的映射(Mapping)用來定義一個(gè)文檔,可以定義所包含的字段以及字段的類型、分詞器及屬性等等

????????映射可以分為動(dòng)態(tài)映射和靜態(tài)映射:

  1. 動(dòng)態(tài)映射(dynamic mapping):在關(guān)系數(shù)據(jù)庫中,需要事先創(chuàng)建數(shù)據(jù)庫,然后在該數(shù)據(jù)庫實(shí)例下創(chuàng)建數(shù)據(jù)表,然后才能在該數(shù)據(jù)表中插入數(shù)據(jù)。而ElasticSearch中不需要事先定義映射(Mapping),文檔寫入ElasticSearch時(shí),會(huì)根據(jù)文檔字段自動(dòng)識(shí)別類型。這種機(jī)制稱之為動(dòng)態(tài)映射
  2. 靜態(tài)映射 :在ElasticSearch中也可以事先定義好映射,包含文檔的各個(gè)字段及其類型等,這種方式稱之為靜態(tài)映射

2、Mapping字段常用類型

1)字符串(text、keyword)

  • text:可分詞,不可參與聚合
  • keyword:不可分詞,數(shù)據(jù)會(huì)作為完整字段進(jìn)行匹配,可以參與聚合

es mapping,Es,學(xué)習(xí),elasticsearch,大數(shù)據(jù)

?2)整數(shù)

es mapping,Es,學(xué)習(xí),elasticsearch,大數(shù)據(jù)

?3)浮點(diǎn)類型

es mapping,Es,學(xué)習(xí),elasticsearch,大數(shù)據(jù)

?4)date類型

  • 日期格式的字符串,比如"2018-01-13"或"2018-01-13 12:10:30"
  • long類型的毫秒數(shù)(從1970年開始)
  • integer的秒數(shù)

5)?boolean類型

????????邏輯類型(布爾類型)可以接受true/false

6)?binary類型

????????二進(jìn)制字段是指base64來表示索引中儲(chǔ)存的二進(jìn)制數(shù)據(jù),可用來儲(chǔ)存二進(jìn)制形式的數(shù)據(jù),例如圖像。默認(rèn)情況下,該類型的字段只儲(chǔ)存不索引。二進(jìn)制只支持index_name屬性

7)array類型

8)object類型

????????JSON天生具有層級(jí)關(guān)系,文檔會(huì)包含嵌套的對(duì)象

3、映射中對(duì)時(shí)間類型詳解

????????假如我們有如下索引tax,保存了一些公司的納稅或資產(chǎn)信息,單位為"萬元"。當(dāng)前這個(gè)例子里。索引達(dá)的含義并不重要,關(guān)鍵點(diǎn)在于字段的內(nèi)容格式。我們看到date字段其中包含了多種日期的格式:“yyyy-MM-dd”,"yyyy-MM-dd"還有時(shí)間戳。

1)采取自動(dòng)映射器來映射

????????如果按照dynamic mapping,采取自動(dòng)映射器來映射索引,我們自然而然的都會(huì)感覺字段應(yīng)該是一個(gè)date類型;我們把數(shù)據(jù)存入索引然后查看tax索引的mapping;

POST tax/_bulk
{"index":{}}
{"date": "2021-01-27 10:01:54","company": "騰訊","ratal": 6500}
{"index":{}}
{"date": "2021-01-28 10:01:32","company": "螞蟻金服","ratal": 5000}
{"index":{}}
{"date": "2021-01-29 10:01:21","company": "字節(jié)跳動(dòng)","ratal": 10000}
{"index":{}}
{"date": "2021-01-30 10:02:07","company": "中國(guó)石油","ratal": 18302097}
{"index":{}}
{"date": "1648100904","company": "中國(guó)石化","ratal": 32654722}
{"index":{}}
{"date": "2021-11-1 12:20:00","company": "國(guó)家電網(wǎng)","ratal": 82950000}

查看tax索引的mapping:

"properties" : {
  "date" : {
    "type" : "text","fields" : {
      "keyword" : {
        "type" : "keyword","ignore_above" : 256
      }
    }
  }
}

? ? ? ? 我們可以看到date居然是一個(gè)text類型。這是為什么呢,原因就在于對(duì)時(shí)間類型的格式的要求是絕對(duì)嚴(yán)格的。要求必須是一個(gè)標(biāo)準(zhǔn)的UTC時(shí)間類型。上述字段的數(shù)據(jù)格式如果想要使用,就必須使用yyyy-MM-ddTHH:mm:ssZ格式(其中T個(gè)間隔符,Z代表 0 時(shí)區(qū));

????????錯(cuò)誤的時(shí)間格式均無法被自動(dòng)映射器識(shí)別為日期時(shí)間類型,例如:

  1. yyyy-MM-dd HH:mm:ss
  2. yyyy-MM-dd
  3. 時(shí)間戳
  4. 2022-4-30T20:00:00Z

2)手工映射提前指定日期類型

PUT tax
{
 "mappings": {
   "properties": {
     "date": {
       "type": "date"
     }
   }
 }
}
POST tax/_bulk
{"index":{}}
{"date": "2021-01-30 10:02:07","ratal": 32654722}
{"index":{}}
{"date": "2021-11-1T12:20:00Z","ratal": 82950000}
{"index":{}}
{"date": "2021-01-30T10:02:07Z","ratal": 18302097}
{"index":{}}
{"date": "2021-01-25","ratal": 5700000}

第一個(gè)(寫入失敗):2021-01-30 10:02:07

第二個(gè)(寫入成功):1648100904

第三個(gè)(寫入失敗):2021-11-1T12:20:00Z

第四個(gè)(寫入成功):2021-01-30T10:02:07Z

第五個(gè)(寫入成功):2021-01-25

總結(jié):

1.對(duì)于yyyy-MM-dd HH:mm:ss或2021-11-1T12:20:00Z,ES 的自動(dòng)映射器完全無法識(shí)別,即便是事先聲明日期類型,數(shù)據(jù)強(qiáng)行寫入也會(huì)失敗

2.對(duì)于時(shí)間戳和yyyy-MM-dd這樣的時(shí)間格式,ES 自動(dòng)映射器無法識(shí)別,但是如果事先說明了日期類型是可以正常寫入的

3.對(duì)于標(biāo)準(zhǔn)的日期時(shí)間類型是可以正常自動(dòng)識(shí)別為日期類型,并且也可以通過手工映射來實(shí)現(xiàn)聲明字段類型

實(shí)際開發(fā)中的解決方法:

//只需要在字段屬性中添加一個(gè)參數(shù):
“format”: “yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis”,這樣就可以避免因?yàn)閿?shù)據(jù)格式不統(tǒng)一而導(dǎo)致數(shù)據(jù)無法寫入的窘境
PUT test_index
{
 "mappings": {
   "properties": {
     "time": {
       "type": "date","format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
     }
   }
 }
}

4、ES的keyword的屬性ignore_above

????????在es的5.x版本,keyword類型字段可以設(shè)置ignore_above,表示最大的字段值長(zhǎng)度,超出這個(gè)長(zhǎng)度的字段將不會(huì)被索引,但是會(huì)存儲(chǔ);舉個(gè)例子:設(shè)置message 的長(zhǎng)度最長(zhǎng)為20,超過20的不被索引,這里的不被索引是這個(gè)字段不被索引,但是其他字段有的話仍然被索引到;

PUT my_index
{
  "mappings": {
    "my_type": {
      "properties": {
        "message": {
          "type": "keyword",
          "ignore_above": 20 
        }
      }
    }
  }
}
# 下面造點(diǎn)數(shù)據(jù)
PUT my_index/my_type/3 
{
  "message": "123456789"
}

PUT my_index/my_type/5
{
  "message": "123456789012345678901"
}

全部查詢:

es mapping,Es,學(xué)習(xí),elasticsearch,大數(shù)據(jù)

?模糊匹配:

es mapping,Es,學(xué)習(xí),elasticsearch,大數(shù)據(jù)

????????我們可以發(fā)現(xiàn)你用模糊匹配是搜索不到的(注意上面的數(shù)據(jù)最后帶個(gè)1是21位下圖是20位的),同樣?用精確匹配前面20個(gè)仍然搜索不到;

5、Mapping映射的查看和創(chuàng)建

1)查看mapping信息:GET 索引名/_mapping

 {
    "bank" : {
      "mappings" : {
        "properties" : {
          "account_number" : {
            "type" : "long" # long類型
          },
          "address" : {
            "type" : "text", # 文本類型,會(huì)進(jìn)行全文檢索,進(jìn)行分詞
            "fields" : {
              "keyword" : { # addrss.keyword
                "type" : "keyword",  # 該字段必須全部匹配到
                "ignore_above" : 256
              }
            }
          },
          "age" : {
            "type" : "long"
          },
          "balance" : {
            "type" : "long"
          },
          "city" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "email" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "employer" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "firstname" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "gender" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "lastname" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          },
          "state" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }
        }
      }
    }
  }

ElasticSearch7-去掉type概念:

1、關(guān)系型數(shù)據(jù)庫中兩個(gè)數(shù)據(jù)表示是獨(dú)立的,即使他們里面有相同名稱的列也不影響使用,但ES中不是這樣的。elasticsearch是基于Lucene開發(fā)的搜索引擎,而ES中不同type下名稱相同的filed最終在Lucene中的處理方式是一樣的

  • (1)兩個(gè)不同type下的兩個(gè)user_name,在ES同一個(gè)索引下其實(shí)被認(rèn)為是同一個(gè)filed,你必須在兩個(gè)不同的type中定義相同的filed映射。否則,不同type中的相同字段名稱就會(huì)在處理中出現(xiàn)沖突的情況,導(dǎo)致Lucene處理效率下降。
  • (2)去掉type就是為了提高ES處理數(shù)據(jù)的效率。

2、Elasticsearch 7.x URL中的type參數(shù)為可選。比如,索引一個(gè)文檔不再要求提供文檔類型
3、Elasticsearch 8.x 不再支持URL中的type參數(shù)

解決:將索引從多類型遷移到單類型,每種類型文檔一個(gè)獨(dú)立索引;將已存在的索引下的類型數(shù)據(jù),全部遷移到指定位置即可;

2)創(chuàng)建映射:PUT /索引名

創(chuàng)建Mapping映射語法:

PUT /索引庫名/_mapping
{
  "properties": {
    "字段名": {
      "type": "類型",  # type:類型,可以是text、long、short、date、integer、object等
      "index": true,  # index:是否索引,默認(rèn)為true
      "store": false, # store:是否存儲(chǔ),默認(rèn)為false
      "analyzer": "分詞器" # analyzer:指定分詞器
    }
  }
}
PUT /company-index/_mapping
{
  "properties": {
    "name": {
      "type": "text",
      "index": true,
      "analyzer": "ik_max_word"
    },
    "job": {
      "type": "text",
      "analyzer": "ik_max_word"
    },
    "logo": {
      "type": "keyword",
      "index": false
    },
    "payment": {
      "type": "float"
    }
  }
}

1、index影響字段的索引情況:

  • true:字段會(huì)被索引,則可以用來進(jìn)行搜索。默認(rèn)值就是true
  • false:字段不會(huì)被索引,不能用來搜索

????????index的默認(rèn)值就是true,也就是說你不進(jìn)行任何配置,所有字段都會(huì)被索引。但是有些字段是我們不希望被索引的,比如企業(yè)的logo圖片地址,就需要手動(dòng)設(shè)置index為false;

2、store:是否將數(shù)據(jù)進(jìn)行獨(dú)立存儲(chǔ):

????????原始的文本會(huì)存儲(chǔ)在_source里面,默認(rèn)情況下其他提取出來的字段都不是獨(dú)立存儲(chǔ)的,是從_source里面提取出來的。當(dāng)然你也可以獨(dú)立的存儲(chǔ)某個(gè)字段,只要設(shè)置store:true即可,獲取獨(dú)立存儲(chǔ)的字段要比從_source中解析快得多,但是也會(huì)占用更多的空間,所以要根據(jù)實(shí)際業(yè)務(wù)需求來設(shè)置,默認(rèn)為false;

3、analyzer:指定分詞器:

????????一般我們處理中文會(huì)選擇ik分詞器 ik_max_word、ik_smart

PUT /my_index
{
  "mappings": {
    "properties": {
      "age": {
        "type": "integer"
      },
      "email": {
        "type": "keyword" # 指定為keyword
      },
      "name": {
        "type": "text" # 全文檢索。保存時(shí)候分詞,檢索時(shí)候進(jìn)行分詞匹配
      }
    }
  }
}
輸出:
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "my_index"
}
查看映射GET /my_index
輸出結(jié)果:
{
  "my_index" : {
    "aliases" : { },
    "mappings" : {
      "properties" : {
        "age" : {
          "type" : "integer"
        },
        "email" : {
          "type" : "keyword"
        },
        "employee-id" : {
          "type" : "keyword",
          "index" : false
        },
        "name" : {
          "type" : "text"
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1588410780774",
        "number_of_shards" : "1",
        "number_of_replicas" : "1",
        "uuid" : "ua0lXhtkQCOmn7Kh3iUu0w",
        "version" : {
          "created" : "7060299"
        },
        "provided_name" : "my_index"
      }
    }
  }
}
# 添加新的字段映射PUT /my_index/_mapping
PUT /my_index/_mapping
{
  "properties": {
    "employee-id": {
      "type": "keyword",
      "index": false # 字段不能被檢索。檢索
    }
  }
}
這里的 "index": false,表明新增的字段不能被檢索,只是一個(gè)冗余字段。

注意:不能更新映射:對(duì)于已經(jīng)存在的字段映射,我們不能更新。更新必須創(chuàng)建新的索引,進(jìn)行數(shù)據(jù)遷移

3)?查看所有索引映射關(guān)系

  1. GET _mapping
  2. GET _all/_mapping

4)修改索引映射關(guān)系

PUT /索引庫名/_mapping
{
  "properties": {
    "字段名": {
      "type": "類型",
      "index": true,
      "store": true,
      "analyzer": "分詞器"
    }
  }
}

注意:這里修改映射是增加字段,做其它更改只能刪除索引重新建立映射

5)一次性創(chuàng)建索引和映射

put /索引庫名稱
{
  "settings": {
    "索引庫屬性名": "索引庫屬性值"
  },
  "mappings": {
    "properties": {
      "字段名": {
        "映射屬性名": "映射屬性值"
      }
    }
  }
}

6、數(shù)據(jù)遷移-reindex

????????先創(chuàng)建new_twitter的正確映射,然后使用如下方式進(jìn)行數(shù)據(jù)遷移

6.0以后寫法
POST reindex
{
  "source":{
      "index":"twitter"
   },
  "dest":{
      "index":"new_twitters"
   }
}


老版本寫法
POST reindex
{
  "source":{
      "index":"twitter",
      "type":"twitter"
   },
  "dest":{
      "index":"new_twitters"
   }
}

案例:原來類型為account,新版本沒有類型了,所以我們把他去掉;想要將年齡修改為integer,先創(chuàng)建新的索引;

1.原索引:

GET /bank/_search
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1000,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "bank",
        "_type" : "account",//原來類型為account,新版本沒有類型了,所以我們把他去掉
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "account_number" : 1,
          "balance" : 39225,
          "firstname" : "Amber",
          "lastname" : "Duke",
          "age" : 32,
          "gender" : "M",
          "address" : "880 Holmes Lane",
          "employer" : "Pyrami",
          "email" : "amberduke@pyrami.com",
          "city" : "Brogan",
          "state" : "IL"
        }
      },
      ...
GET /bank/_search
查出
"age":{"type":"long"}

2.創(chuàng)建新的索引:

PUT /newbank
{
  "mappings": {
    "properties": {
      "account_number": {
        "type": "long"
      },
      "address": {
        "type": "text"
      },
      "age": {
        "type": "integer"
      },
      "balance": {
        "type": "long"
      },
      "city": {
        "type": "keyword"
      },
      "email": {
        "type": "keyword"
      },
      "employer": {
        "type": "keyword"
      },
      "firstname": {
        "type": "text"
      },
      "gender": {
        "type": "keyword"
      },
      "lastname": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "state": {
        "type": "keyword"
      }
    }
  }
}
查看"newbank"的映射:
GET /newbank/_mapping
能夠看到age的映射類型被修改為了integer.
"age":{"type":"integer"}

3.將bank中的數(shù)據(jù)遷移到newbank中:

POST _reindex
{
  "source": {
    "index": "bank",
    "type": "account"
  },
  "dest": {
    "index": "newbank"
  }
}
運(yùn)行輸出:
#! Deprecation: [types removal] Specifying types in reindex requests is deprecated.
{
  "took" : 768,
  "timed_out" : false,
  "total" : 1000,
  "updated" : 0,
  "created" : 1000,
  "deleted" : 0,
  "batches" : 1,
  "version_conflicts" : 0,
  "noops" : 0,
  "retries" : {
    "bulk" : 0,
    "search" : 0
  },
  "throttled_millis" : 0,
  "requests_per_second" : -1.0,
  "throttled_until_millis" : 0,
  "failures" : [ ]
}

4.查看newbank中的數(shù)據(jù):

GET /newbank/_search

輸出
  "hits" : {
    "total" : {
      "value" : 1000,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "newbank",
        "_type" : "_doc", # 沒有了類型

7、ik_max_word、ik_smart分詞器

????????一個(gè)tokenizer(分詞器)接收一個(gè)字符流,將之分割為獨(dú)立的tokens(詞元,通常是獨(dú)立的單詞),然后輸出tokens流;例如:whitespace tokenizer遇到空白字符時(shí)分割文本。它會(huì)將文本"Quick brown fox!"分割為(Quick,brown,fox!);

????????該tokenizer(分詞器)還負(fù)責(zé)記錄各個(gè)terms(詞條)的順序或position位置(用于phrase短語和word proximity詞近鄰查詢),以及term(詞條)所代表的原始word(單詞)的start(起始)和end(結(jié)束)的character offsets(字符串偏移量)(用于高亮顯示搜索的內(nèi)容)。elasticsearch提供了很多內(nèi)置的分詞器(標(biāo)準(zhǔn)分詞器),可以用來構(gòu)建custom analyzers(自定義分詞器)。

? ? ? ? 分詞器的安裝:根據(jù)當(dāng)前es的版本,去找到對(duì)應(yīng)版本的分詞器,下載.zip文件,然后解壓到elasticsearch/plugins文件夾下即可,注意需要將權(quán)限進(jìn)行修改chmod -R 777 plugins/ik;安裝完畢后,需要重啟elasticsearch容器。

POST _analyze
{
  "analyzer": "standard",
  "text": "The 2 Brown-Foxes bone."
}
執(zhí)行結(jié)果:
{
  "tokens" : [
    {
      "token" : "the",
      "start_offset" : 0,
      "end_offset" : 3,
      "type" : "<ALPHANUM>",
      "position" : 0
    },
    {
      "token" : "2",
      "start_offset" : 4,
      "end_offset" : 5,
      "type" : "<NUM>",
      "position" : 1
    },
    {
      "token" : "brown",
      "start_offset" : 6,
      "end_offset" : 11,
      "type" : "<ALPHANUM>",
      "position" : 2
    },
    {
      "token" : "foxes",
      "start_offset" : 12,
      "end_offset" : 17,
      "type" : "<ALPHANUM>",
      "position" : 3
    },
    {
      "token" : "bone",
      "start_offset" : 18,
      "end_offset" : 22,
      "type" : "<ALPHANUM>",
      "position" : 4
    }
  ]
}

????????ik_max_word:會(huì)將文本做最細(xì)粒度的拆分,比如會(huì)將"湖南省岳陽縣"拆分為"湖南省、湖南、省、 岳陽縣、岳陽、縣等詞語(索引的時(shí)候用ik_max_word):

GET _analyze
{
   "analyzer": "ik_max_word", 
   "text":"湖南省岳陽縣"
}
{
  "tokens" : [
    {
      "token" : "湖南省",
      "start_offset" : 0,
      "end_offset" : 3,
      "type" : "CN_WORD",
      "position" : 0
    },
    {
      "token" : "湖南",
      "start_offset" : 0,
      "end_offset" : 2,
      "type" : "CN_WORD",
      "position" : 1
    },
    {
      "token" : "省",
      "start_offset" : 2,
      "end_offset" : 3,
      "type" : "CN_CHAR",
      "position" : 2
    },
    {
      "token" : "岳陽縣",
      "start_offset" : 3,
      "end_offset" : 6,
      "type" : "CN_WORD",
      "position" : 3
    },
    {
      "token" : "岳陽",
      "start_offset" : 3,
      "end_offset" : 5,
      "type" : "CN_WORD",
      "position" : 4
    },
    {
      "token" : "縣",
      "start_offset" : 5,
      "end_offset" : 6,
      "type" : "CN_CHAR",
      "position" : 5
    }
  ]
}

????????ik_smart:會(huì)做最粗粒度的拆分,比如會(huì)將"湖南省岳陽縣"拆分為湖南省、岳陽縣(前臺(tái)搜索的時(shí)候用 ik_smart):

GET _analyze
{
   "analyzer": "ik_smart", 
   "text":"湖南省岳陽縣"
}
 {
 "tokens" : [
   {
     "token" : "湖南省",
     "start_offset" : 0,
     "end_offset" : 3,
     "type" : "CN_WORD",
     "position" : 0
   },
   {
     "token" : "岳陽縣",
     "start_offset" : 3,
     "end_offset" : 6,
     "type" : "CN_WORD",
     "position" : 1
   }
 ]
}

????????用戶還可以通過修改elasticsearch/plugins/ik/config中的IKAnalyzer.cfg.xml文件自定義分詞器;

參考原文地址:http://t.csdn.cn/WK4mn文章來源地址http://www.zghlxwxcb.cn/news/detail-806765.html

到了這里,關(guān)于【Elasticsearch學(xué)習(xí)筆記二】es的Mapping字段映射、Mapping字段常用類型、Mapping映射的創(chuàng)建、查看和更新、es數(shù)據(jù)遷移、ik分詞器的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Elasticsearch(019):es常見的字段映射類型之?dāng)?shù)組類型(arrays)

    在Elasticsearch中,沒有專用的array數(shù)據(jù)類型。默認(rèn)情況下,任何字段都可以包含零個(gè)或多個(gè)值,但是,數(shù)組中的所有值都必須具有相同的數(shù)據(jù)類型。 這一點(diǎn)是區(qū)別于nested的,nested指的對(duì)象的集合。而arrays則是單一類型的數(shù)組集合而已。 此外,不需要專門的類型類定義數(shù)組類型

    2024年02月13日
    瀏覽(24)
  • Elasticsearch (ES) 搜索引擎: 數(shù)據(jù)類型、動(dòng)態(tài)映射、多類型(子字段)

    原文鏈接:https://xiets.blog.csdn.net/article/details/132348634 版權(quán)聲明:原創(chuàng)文章禁止轉(zhuǎn)載 專欄目錄:Elasticsearch 專欄(總目錄) ES 映射字段的 數(shù)據(jù)類型 ,官網(wǎng)文檔參考:Field data types。 下面是 ES 常用的一些基本數(shù)據(jù)類型。 字符串 類型: keyword :類型。 text :文本類型。

    2024年03月23日
    瀏覽(38)
  • ElasticSearch系列 - SpringBoot整合ES:映射中定義字段的數(shù)據(jù)類型及屬性

    ElasticSearch - SpringBoot整合ES:映射定義字段的數(shù)據(jù)類型及屬性 01. ElasticSearch 搜索結(jié)果的準(zhǔn)確性和召回率是什么? 在Elasticsearch中,搜索結(jié)果的準(zhǔn)確性和召回率是非常重要的指標(biāo),它們反映了搜索引擎的性能和效果。以下是這兩個(gè)指標(biāo)的定義和解釋: 準(zhǔn)確性:搜索結(jié)果的準(zhǔn)確性

    2024年02月08日
    瀏覽(25)
  • (4)elasticsearch的Mapping(映射)

    映射是定義文檔及其包含的字段的存儲(chǔ)和索引方式的過程。 兩種映射方式 dynamic mapping(動(dòng)態(tài)映射或自動(dòng)映射) expllcit mapping(靜態(tài)映射或手工映射或顯示映射) Mapping數(shù)據(jù)類型 Mapping參數(shù) https://www.elastic.co/guide/en/elasticsearch/reference/7.10/removal-of-types.html Mapping 也稱之為映射,定義

    2024年02月03日
    瀏覽(63)
  • es獲取mapping中所有的字段(回溯)

    es獲取mapping中所有的字段(回溯)

    ????????有時(shí)候想看看es中某個(gè)索引中所有的字段,直接通過查詢mapping是很難看出所有的字段的,里面包含的屬性太多了。本博文將實(shí)現(xiàn)獲取mapping中所有字段的算法。 示例new_user2索引中的mapping值: 示例代碼: 【直接在mapping中獲取】 運(yùn)行結(jié)果: 注意: 也可以直接通過查

    2024年02月11日
    瀏覽(15)
  • elasticsearch中文檔映射Mapping用法詳解

    elasticsearch中文檔映射Mapping用法詳解

    Mapping類似數(shù)據(jù)庫中的schema的定義,作用如下: 定義索引中的字段的名稱 定義字段的數(shù)據(jù)類型,例如字符串,數(shù)字,布爾等 字段,倒排索引的相關(guān)配置(Analyzed or Not Analyzed,Analyzer) ES中Mapping映射可以分為動(dòng)態(tài)映射和靜態(tài)映射。 動(dòng)態(tài)映射: ????????在關(guān)系數(shù)據(jù)庫中,需要事先創(chuàng)

    2024年02月16日
    瀏覽(28)
  • Elasticsearch:Explicit mapping - 顯式映射

    Elasticsearch:Explicit mapping - 顯式映射

    顯式映射相比較動(dòng)態(tài)映射(Dynamic mapping)是需要我們?cè)谒饕齽?chuàng)建時(shí)就定義字段及其類型。這個(gè)和我們傳統(tǒng)的 RDMS 數(shù)據(jù)庫一樣,在我們寫入數(shù)據(jù)到數(shù)據(jù)庫之前,我們需要工整地定義好每個(gè)字段及其類型和長(zhǎng)度。Elasticsearch 既可以使用顯式映射也可以同時(shí)使用動(dòng)態(tài)映射。在許多的

    2024年02月02日
    瀏覽(22)
  • Elasticsearch:映射(mapping)的實(shí)用實(shí)踐指南

    Elasticsearch:映射(mapping)的實(shí)用實(shí)踐指南

    動(dòng)態(tài)映射適用于開發(fā)環(huán)境,但對(duì)于生產(chǎn)級(jí)集群禁用它。 將動(dòng)態(tài)配置為 “strict” 以對(duì)索引的字段值實(shí)施嚴(yán)格模式。有關(guān)動(dòng)態(tài)映射的詳細(xì)描述,請(qǐng)閱讀文章 “Elasticsearch:Dynamic mapping”。 當(dāng)文檔大量存儲(chǔ)時(shí),可以在定義字段映射時(shí)使用優(yōu)化來節(jié)省磁盤空間。 禁用強(qiáng)制(coerce)。

    2024年02月12日
    瀏覽(17)
  • 深入理解Elasticsearch的索引映射(mapping)

    當(dāng)我們談?wù)揈lasticsearch時(shí),索引映射是一個(gè)核心概念,它定義了如何存儲(chǔ)和檢索數(shù)據(jù)。在Elasticsearch 7.6及更高版本中,映射提供了一系列強(qiáng)大的功能,使您能夠精確地控制數(shù)據(jù)的結(jié)構(gòu)和行為。本文將詳細(xì)介紹映射的關(guān)鍵屬性、用途以及如何正確設(shè)置和優(yōu)化它。 在Elasticsearch中,

    2024年02月22日
    瀏覽(39)
  • ElasticSearch索引mapping添加字段

    ElasticSearch索引mapping添加字段

    ES版本5.3.0,在已存在的索引mapping中添加字段。 如下: my_index索引名稱,my_type為索引類型名稱,new_field_name為新增的字段名稱。 如下: 返回為true代表添加操作成功。

    2024年02月13日
    瀏覽(25)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包