mass-data-lucene
  • Introduction
  • 底层lucene(路森)
    • 搜索引擎理论讲解
    • 分词器
    • lucene介绍以及原理
    • lucene索引文件格式
    • lucene索引过程分析
    • lucene搜索过程解析
    • lucene应用
    • 性能分析及调优
    • lucene相关问题
  • Solr篇
    • Solr架构及概念分析
    • 入门
    • 部署和运营
    • 使用Solr管理用户界面
    • 文档,字段和架构设计
    • 了解分析器,标记器和过滤器
    • 索引和基本数据操作
    • 多语言搜索
    • 企业级Solr云实战
    • Solr独立模式
    • SolrCloud集群模式
  • elasticsearch篇([ɪˈlæstɪk] [sɜːtʃ] )
    • 教程
      • 前言
      • linux系统安装es、head、kibana插件
      • linux安装ik分词
      • windows系统安装es
      • es、head、kibana、ik插件安装时遇到问题汇总
      • kibana consle 与sense区别
      • elasticsearch架构及概念分析
      • elasticsearch集群搭建及管理
      • _bulk 批量导入数据
      • elasticsearch基本CURD方法及示例
      • 分词一些基本用法
      • text和keyword类型的区别
      • elasticsearch单台服务器部署多个节点
      • elasticSearch复制索引并修改字段
      • 中文分词与停用词的作用
    • elasticsearch实战
Powered by GitBook
On this page

Was this helpful?

  1. elasticsearch篇([ɪˈlæstɪk] [sɜːtʃ] )
  2. 教程

elasticsearch基本CURD方法及示例

一.索引添加、删除、修改

  • 添加语法

PUT /my_index
{
    "settings": { ... any settings ... },
    "mappings": {
        "type_one": { ... any mappings ... },
        "type_two": { ... any mappings ... },
        ...
    }
}
  • 创建索引的示例

PUT /my_index
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "my_type": {
      "properties": {
        "my_field": {
          "type": "text"
        }
      }
    }
  }
}

或

curl -XPUT '192.168.127.98:9200/my_index?pretty' -d '{   "settings": {     "number_of_shards": 1,     "number_of_replicas": 0   },   "mappings": {     "my_type": {       "properties": {         "my_field": {           "type": "text"         }       }     }   } }'
  • 查看所有索引

curl '192.168.127.98:9200/_cat/indices?v'
  • 修改索引

PUT /my_index/_settings
{
    "number_of_replicas": 1
}

或

curl -XPUT '192.168.127.98:9200/my_index?pretty' -d '{"number_of_replicas": 1 }'
  • 删除索引

DELETE /my_index
DELETE /index_one,index_two
DELETE /index_*
DELETE /_all


可以设置下面的属性,使DELETE /_all 失效,必须指定索引名称,才可以删除。
elasticsearch.yml
action.destructive_requires_name: true

二、文档的添加、删除、修改

  • 添加文档语法

PUT /{index}/{type}/{id}
{
"field": "value",
...
}
  • 添加文档

PUT /my_index/my_type/1
{
  "name": "John Doe"
}

或

curl -XPUT 'localhost:9200/my_index/my_type/1?pretty' -d '{"name": "John Doe"}'
  • 获取所有文档

PUT /my_index/_search
Previous_bulk 批量导入数据Next分词一些基本用法

Last updated 5 years ago

Was this helpful?