ElasticSearch建立索引
已經搭建好了IK中文分詞環境.
http://blog.itpub.net/29254281/viewspace-2095945/
將資料庫的表對映為ES索引.索引歌曲ID,歌曲名稱和演唱者
建立索引結構
index.json:
{
"mappings":{
"sod_song_ksc":{
"properties":{
"songid":{"type":"long","store":"yes","index":"not_analyzed"},
"name":{"type":"string","store":"yes","index":"analyzed","analyzer":"ik"},
"singername":{"type":"string","store":"yes","index":"analyzed","analyzer":"ik"}
}
}
}
}
curl -XPOST http://192.168.1.105:9200/songod --data-binary @index.json
批次匯入資料
[elasticsearch/tmp]$curl -XPUT http://192.168.1.105:9200/_bulk -d'
> {"create":{"_index":"songod","_type":"sod_song_ksc","_id":90978059}}
> {"songid":90978059,"songname":"思念一個荒廢的名字","singername":"陳楚生"}
> {"create":{"_index":"songod","_type":"sod_song_ksc","_id":90978058}}
> {"songid":90978058,"songname":"讓愛綻放","singername":"陳慧嫻"}
> {"create":{"_index":"songod","_type":"sod_song_ksc","_id":90978057}}
> {"songid":90978057,"songname":"天邊有個你","singername":"陳思思"}
> {"create":{"_index":"songod","_type":"sod_song_ksc","_id":90978052}}}
> {"songid":90978052,"songname":"那些讓你死去活來的女孩","singername":"陳奕迅"}
> {"create":{"_index":"songod","_type":"sod_song_ksc","_id":90978048}}
> {"songid":90978048,"songname":"石壁我的家園","singername":"阿魯阿卓"}
> '
檢視匯入資料
http://192.168.1.105:9200/songod/sod_song_ksc/_search?q=*&pretty
curl -XDELETE http://192.168.1.105:9200/songod/
http://blog.itpub.net/29254281/viewspace-2095945/
將資料庫的表對映為ES索引.索引歌曲ID,歌曲名稱和演唱者
建立索引結構
index.json:
{
"mappings":{
"sod_song_ksc":{
"properties":{
"songid":{"type":"long","store":"yes","index":"not_analyzed"},
"name":{"type":"string","store":"yes","index":"analyzed","analyzer":"ik"},
"singername":{"type":"string","store":"yes","index":"analyzed","analyzer":"ik"}
}
}
}
}
curl -XPOST http://192.168.1.105:9200/songod --data-binary @index.json
批次匯入資料
[elasticsearch/tmp]$curl -XPUT http://192.168.1.105:9200/_bulk -d'
> {"create":{"_index":"songod","_type":"sod_song_ksc","_id":90978059}}
> {"songid":90978059,"songname":"思念一個荒廢的名字","singername":"陳楚生"}
> {"create":{"_index":"songod","_type":"sod_song_ksc","_id":90978058}}
> {"songid":90978058,"songname":"讓愛綻放","singername":"陳慧嫻"}
> {"create":{"_index":"songod","_type":"sod_song_ksc","_id":90978057}}
> {"songid":90978057,"songname":"天邊有個你","singername":"陳思思"}
> {"create":{"_index":"songod","_type":"sod_song_ksc","_id":90978052}}}
> {"songid":90978052,"songname":"那些讓你死去活來的女孩","singername":"陳奕迅"}
> {"create":{"_index":"songod","_type":"sod_song_ksc","_id":90978048}}
> {"songid":90978048,"songname":"石壁我的家園","singername":"阿魯阿卓"}
> '
檢視匯入資料
http://192.168.1.105:9200/songod/sod_song_ksc/_search?q=*&pretty
{ "took" : 4, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 5, "max_score" : 1.0, "hits" : [ { "_index" : "songod", "_type" : "sod_song_ksc", "_id" : "90978057", "_score" : 1.0, "_source" : { "songid" : 90978057, "songname" : "天邊有個你", "singername" : "陳思思" } }, { "_index" : "songod", "_type" : "sod_song_ksc", "_id" : "90978059", "_score" : 1.0, "_source" : { "songid" : 90978059, "songname" : "思念一個荒廢的名字", "singername" : "陳楚生" } }, { "_index" : "songod", "_type" : "sod_song_ksc", "_id" : "90978058", "_score" : 1.0, "_source" : { "songid" : 90978058, "songname" : "讓愛綻放", "singername" : "陳慧嫻" } }, { "_index" : "songod", "_type" : "sod_song_ksc", "_id" : "90978048", "_score" : 1.0, "_source" : { "songid" : 90978048, "songname" : "石壁我的家園", "singername" : "阿魯阿卓" } }, { "_index" : "songod", "_type" : "sod_song_ksc", "_id" : "90978052", "_score" : 1.0, "_source" : { "songid" : 90978052, "songname" : "那些讓你死去活來的女孩", "singername" : "陳奕迅" } } ] } }刪除索引
curl -XDELETE http://192.168.1.105:9200/songod/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29254281/viewspace-2095990/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- elasticsearch(三)----索引建立與刪除Elasticsearch索引
- Elasticsearch5.x建立索引(Java)ElasticsearchH5索引Java
- python建立elasticsearch索引的探討PythonElasticsearch索引
- ElasticSearch分片互動過程(建立索引、刪除索引、查詢索引)Elasticsearch索引
- 【Elasticsearch】Elasticsearch 索引模板Elasticsearch索引
- Elasticsearch6.2.4-利用head外掛建立索引Elasticsearch索引
- Elasticsearch索引。Elasticsearch索引
- Elasticsearch Query DSL建立滾動索引(生命週期策略)Elasticsearch索引
- ElasticSearch 索引 VS MySQL 索引Elasticsearch索引MySql
- elasticsearch索引原理Elasticsearch索引
- Elasticsearch 學習索引Elasticsearch索引
- elasticsearch配置注入索引Elasticsearch索引
- 剖析 Elasticsearch 的索引原理Elasticsearch索引
- elasticsearch之多索引查詢Elasticsearch索引
- elasticsearch如何設計索引Elasticsearch索引
- Elasticsearch(三):索引查詢Elasticsearch索引
- Elasticsearch 索引容量管理實踐Elasticsearch索引
- ElasticSearch 倒排索引(Inverted Index)| 什麼是倒排索引?Elasticsearch索引Index
- 使用Elasticsearch的動態索引和索引優化Elasticsearch索引優化
- DocumentDB 建立索引索引
- ElasticSearch連線池建立Elasticsearch
- Elasticsearch 7.x:2、索引管理Elasticsearch索引
- Elasticsearch索引生命週期管理方案Elasticsearch索引
- 教你如何在 elasticsearch 中重建索引Elasticsearch索引
- Elasticsearch之索引模板index template與索引別名index aliasElasticsearch索引Index
- mysql建立字首索引MySql索引
- Elasticsearch 索引的對映配置詳解Elasticsearch索引
- Elasticsearch核心技術(四):索引原理分析Elasticsearch索引
- Elasticsearch ILM DSL 索引生命週期管理Elasticsearch索引
- ElasticSearch 獲取es資訊以及索引操作Elasticsearch索引
- mongodb建立索引和刪除索引和背景索引backgroundMongoDB索引
- mysql 建立索引的方法--建立檢視MySql索引
- 【Oracle】-【建立索引】-建立索引的操作原理與一些體會Oracle索引
- 索引組織表上建立BITMAP索引(三)索引
- 索引組織表上建立BITMAP索引(二)索引
- 索引組織表上建立BITMAP索引(一)索引
- MySQL建立索引、修改索引、刪除索引的命令語句MySql索引
- postgresql怎麼建立索引SQL索引