elasticsearch for windows为啥不能创建索引
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticsearch for windows为啥不能创建索引相关的知识,希望对你有一定的参考价值。
创建es索引工具/原料
Elasticsearch服务器
linux curl工具
方法/步骤
1、大致创建索引的格式:
PUT /my_index "settings": ... any settings ... , "mappings": "type_one": ... any mappings ... , "type_two": ... any mappings ... , ...
默认不设置索引也能自动创建,可以通过修改默认配置限制,关闭自动创建索引:
修改配置文件config/elasticsearch.yml,添加如下配置
action.auto_create_index: false
2、最简单的方式创建索引 curl -XPUT ‘http://localhost:9200/twitter/'在创建索引的时候指定分片和副本数量参数,参数格式采用JSON格式curl -XPUT ‘http://localhost:9200/twitter/‘ -d ‘ “settings”: “index”: “number_of_shards”:3, “number_of_replicas”:2 ’或者简化为curl -XPUT ‘http://localhost:9200/twitter’ -d ‘ “settings”: “number_of_shards”:3, “number_of_replicas”:2 ’
注意:不需要在settings项中显示的指定index。
3、索引创建API可以接受一个或者一组映射(Type)选项curl -XPOST localhost:9200/test -d ‘ “settings”: “number_of_shards”:1 , “mappings”: “type1”: “_source”:“enabled”:false, “preperties”: “field1”: “type”:”string”, ”index”:”not_analyzed” ’ 参考技术A ElasticSearch是一个基于Lucene的稳定的、分布式、RESTFul的搜索引擎。其实所谓的RestFul就是它提供URL供你调用(建立索引和进行检索),不过直接这样使用实在是太凶残了。所以,它也提供了一系列client包,相当于将curl请求封装了,client包支持的语言包括Java、php、Python、Ruby和Perl等等。PHP版的client包叫做elasticsearch-php,可以在Git_hub上下载。
要使用elasticsearch-php有如下三个要求:
1.PHP的版本在5.3.9以上,我用的是PHP5.3.23本回答被提问者采纳
ElasticSearch入门 第一篇:Windows下安装ElasticSearch
这是ElasticSearch 2.4 版本系列的第一篇:
- ElasticSearch入门 第一篇:Windows下安装ElasticSearch
- ElasticSearch入门 第二篇:集群配置
- ElasticSearch入门 第三篇:索引
- ElasticSearch入门 第四篇:使用C#添加和更新文档
- ElasticSearch入门 第五篇:使用C#查询文档
- ElasticSearch入门 第六篇:复合数据类型——数组,对象和嵌套
- ElasticSearch入门 第七篇:分析器
- ElasticSearch入门 第八篇:存储
- ElasticSearch入门 第九篇:实现正则表达式查询的思路
ES是一个基于Lucene的分布式全文搜索服务器,和SQL Server的全文索引(Fulltext Index)有点类似,都是基于分词和分段的全文搜索引擎,具有分词,同义词,词干查询的功能,但是ES天生具有分布式和实时的属性,本随笔演示在Windows环境中安装ElasticSearch,以及用于管理ElasticSearch的Head插件。
ElasticSearch官网:http://www.elasticsearch.org
java环境
我安装的是java1.8.x版本的,没安下面的步骤来安装,但有一点,需要设置JAVA_HOME环境变量和path配置
二,安装ElasticSearch
在安装Java JDK,配置JAVA_HOME环境变量之后,就可以安装Elasticsearch全文搜索引擎了,首先需要下载特定版本的ES安装文件。
1,下载ElasticSearch 2.4.6版本
从官方下载中心 ElasticSearch Download 下载ElasticSearch安装包,在楼主截图时,ES的最新版本是6.x,本文使用旧版本2.4.6,打开 past releases 选择过去的版本安装,下载zip文件格式。楼主选择安装2.4.6版本的原因是6.x 版本不支持Head插件。
2,开启ElasticSearch 服务
将zip文件解压到C盘,进入 C:elasticsearch-2.4.4in 目录,双击执行 elasticsearch.bat,该脚本文件执行 ElasticSearch 安装程序,稍等片刻,打开浏览器,输入 http://localhost:9200 ,显式以下画面,说明ES安装成功。
三,安装head插件
为了便于管理ES,本文使用head插件,这是最初级的管理工具,在浏览器中显示ES集群,索引等信息,十分好用。
1,在命令行中安装插件
按住Windows+R,输入cmd,打开命令行工具,进入到ElasticSearch的bin目录,使用ES命令安装插件
cd C:elasticsearch-2.4.4in plugin install mobz/elasticsearch-head
2,通过网页管理ElasticSearch
在本地浏览器中输入http://localhost:9200/_plugin/head/,如果看到以下截图,说明head插件安装成功。
四,将ElasticSearch 安装成Windows服务(Service)
1,打开DOS命令行界面,切换到ElasticSearch的bin目录,执行
service.bat install
2,启动ElasticSearch服务
service.bat start
3,在run界面,输入 services.msc,查看ElasticSearch服务
五,推荐阅读书籍
推荐书籍:《Elasticsearch服务器开发(第2版)》,该书使用curl工具调用ES的API,实际上,使用Head插件,在Any Request 选项卡中,能够轻易地构造出向ES服务器发送请求的API的URL,实现同样的功能:
例如:使用curl工具向ES服务器发送命令,获取集群的健康状态:
curl -XGET http://127.0.0.1:9200/_cluster/health?pretty
使用Head插件,向ES服务器发送Request,获取集群的健康状态::
来源:http://www.cnblogs.com/ljhdo/p/4887557.html
以上是关于elasticsearch for windows为啥不能创建索引的主要内容,如果未能解决你的问题,请参考以下文章
需要curl命令到ElasticSearch for PowerShell
Install elasticsearch-head: – for Elasticsearch 5.x
使用 Docker-Desktop for Windows,如何配置 sysctl 参数以渗透重新启动?
Elasticsearch Exception:Message not fully read (response) for requestId
ElasticsearchResizing Elasticsearch shards for fun and profit