ElasticSearch入门教程-索引

在本节中,我们将向Elasticsearch添加一些索引,映射和数据。此数据将用于本教程中说明的示例中。

创建索引

PUT http://localhost:9200/schools

请求

它可以包含特定于索引的设置,但是现在,对于默认设置,它是空的。

响应

{"acknowledged": true}

(这意味着创建了索引)

创建映射和添加数据

Elasticsearch将根据请求体中提供的数据自动创建映射,我们将使用其批量功能在此索引中添加多个JSON对象。

POST http://localhost:9200/schools/_bulk

请求

{"index":{"_index":"schools", "_type":"school", "_id":"1"}
}
{"name":"Central School", "description":"CBSE Affiliation", "street":"Nagan","city":"paprola", "state":"HP", "zip":"176115", "location":[31.8955385, 76.8380405],"fees":2000, "tags":["Senior Secondary", "beautiful campus"], "rating":"3.5"
}
{"index":{"_index":"schools", "_type":"school", "_id":"2"}
}
{"name":"Saint Paul School", "description":"ICSE Afiliation", "street":"Dawarka", "city":"Delhi", "state":"Delhi", "zip":"110075","location":[28.5733056, 77.0122136], "fees":5000,"tags":["Good Faculty", "Great Sports"], "rating":"4.5"
}
{"index":{"_index":"schools", "_type":"school", "_id":"3"}
}
{"name":"Crescent School", "description":"State Board Affiliation", "street":"Tonk Road", "city":"Jaipur", "state":"RJ", "zip":"176114","location":[26.8535922, 75.7923988],"fees":2500, "tags":["Well equipped labs"], "rating":"4.5"
}

响应

{"took":328, "errors":false,"items":[{"index":{"_index":"schools", "_type":"school", "_id":"1", "_version":1, "_shards":{"total":2, "successful":1, "failed":0}, "status":201}},{"index":{"_index":"schools", "_type":"school", "_id":"2", "_version":1, "_shards":{"total":2, "successful":1, "failed":0}, "status":201}},{"index":{"_index":"schools", "_type":"school", "_id":"3", "_version":1, "_shards":{"total":2, "successful":1, "failed":0}, "status":201}}]
}

添加另一个索引

创建索引

POST http://localhost:9200/schools_gov

请求

它可以包含特定于索引的设置,但是现在它对于默认设置是空的。

响应

{"acknowledged": true} (This means index is created)

创建映射和添加数据

POST http://localhost:9200/schools_gov/_bulk

请求机构

{"index":{"_index":"schools_gov", "_type":"school", "_id":"1"}
}
{"name":"Model School", "description":"CBSE Affiliation", "street":"silk city","city":"Hyderabad", "state":"AP", "zip":"500030", "location":[17.3903703, 78.4752129],"fees":200, "tags":["Senior Secondary", "beautiful campus"], "rating":"3"
}
{"index":{"_index":"schools_gov", "_type":"school", "_id":"2"}
}
{"name":"Government School", "description":"State Board Affiliation","street":"Hinjewadi", "city":"Pune", "state":"MH", "zip":"411057","location": [18.599752, 73.6821995], "fees":500, "tags":["Great Sports"], "rating":"4"
}

响应

{"took":179, "errors":false, "items":[{"index":{"_index":"schools_gov", "_type":"school", "_id":"1", "_version":1, "_shards":{"total":2, "successful":1, "failed":0}, "status":201}},{"index":{"_index":"schools_gov", "_type":"school", "_id":"2", "_version":1, "_shards":{"total":2, "successful":1, "failed":0}, "status":201}}]
}

ElasticSearch入门教程-索引相关推荐

  1. python elasticsearch 入门教程(二) ---全文搜索

    python elasticsearch 入门教程(二) ---全文搜索 截止目前的搜索相对都很简单:单个姓名,通过年龄过滤.现在尝试下稍微高级点儿的全文搜索--一项 传统数据库确实很难搞定的任务. ...

  2. ElasticSearch 入门教程笔记

    视频教程:[狂神说Java]ElasticSearch7.6.x最新完整教程通俗易懂 视频地址:https://www.bilibili.com/video/BV17a4y1x7zq 拒绝白嫖,感谢狂 ...

  3. ElasticSearch入门教程(1)

    目录 1.1ElasticSearch是什么? 2.1Elasticsearch安装 2.1.1 下载软件 2.2.2使用Postman客户端工具 2.2.3数据格式 正(排)向索引 倒排索引 2.2 ...

  4. Elasticsearch系列-Elasticsearch入门教程

    引言 Elasticsearch是著名的开源分布式搜索和数据处理平台,是一个基于Lucene的分布式.实时.全文搜索系统,其稳定.可靠.高可用.可大规模扩展等特性,使得Elasticsearch的应用 ...

  5. Elasticsearch入门教程

    ElasticSearch是一个高度可扩展的开源搜索引擎并使用REST API,所以您值得拥有. 在本教程中,将介绍开始使用ElasticSearch的一些主要概念. 下载并运行ElasticSear ...

  6. Elasticsearch 入门教程

    目录 一.安装 二.基本概念 2.1 Node 与 Cluster 2.2 Index 2.3 Document 2.4 Type 三.新建和删除 Index 四.中文分词设置 五.数据操作 5.1 ...

  7. ElasticSearch入门教程--安装

    Elasticsearch - 安装 安装Elasticsearch的步骤如下 - 第1步 - 检查安装好计算机的java的最低版本,它应该是java 7或更高版本.您可以通过执行以下操作进行检查 - ...

  8. Elasticsearch入门教程(五):Elasticsearch查询(一)

    // 准备数据 PUT /shop/goods/1 {"name": "2017新款女装冬季外套ulzzang棉袄中长款棉衣韩版百搭棉服面包服","d ...

  9. 全文搜索引擎Elasticsearch入门教程

    全文搜索属于最常见的需求,开源的 Elasticsearch (以下简称 Elastic)是目前全文搜索引擎的首选. 它可以快速地储存.搜索和分析海量数据.维基百科.Stack Overflow.Gi ...

最新文章

  1. 来字节才发现,31岁程序员已经是大团队里最老的了!才发现自己从未真的努力,虽然每天加班到十二点,但只怀着赶紧干完的抱怨!...
  2. Android开发精要1--Android系统架构
  3. 网格合并之后物体的位置改变了_基于网格映射对自动驾驶环境信息表示方法
  4. .NET 5干货来袭 嘉宾李杨桂素伟
  5. RandomForestClassifier(随机森林检测每个特征的重要性及每个样例属于哪个类的概率)...
  6. appconfig文件中的配置节
  7. C++ List的用法(整理)[转载]
  8. 【工具】国密SM4算法加解密
  9. 真无线蓝牙耳机哪个好?四款买了不亏的真无线蓝牙耳机
  10. 程序员为维持游戏开发被迫炒股,竟变成千万富翁
  11. 给定一个无重复元素的数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合
  12. 28岁想入行软件测试,可行吗?
  13. 大连八中学2021年高考成绩查询,2021年大连各高中高考成绩排名及放榜最新消息...
  14. ABAP inner join 性能影响
  15. Comet OJ 2019 夏季欢乐赛题解
  16. 零基础JavaScript-DOM入门(第一天)(第二天)
  17. Python的应用及特点
  18. 软件设计师考试注意事项
  19. Python生物统计学基础教程
  20. java基础学习 day28(就近原则,this关键字,构造方法,标准Javabean类)

热门文章

  1. UIActionSheet与UIAlertView
  2. python——pandas数据分析(表格处理)工具实现Apriori算法
  3. Python __getattr__和__setattr__方法介绍
  4. mysql视图管理和存储过程
  5. oracle数据库查询表的列
  6. 《剑指Offer》 包含min函数的栈
  7. 【今日CV 计算机视觉论文速览 第146期】Mon, 22 Jul 2019
  8. JAVA—object映射转化为long类型方式
  9. Collection的使用 对象 java
  10. c#winform演练 ktv项目 通过下标选中歌曲并且列表高亮