
elasticsearch for windows为什么不能创建索引
2个回答
展开全部
创建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” } } } }}’
工具/原料
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” } } } }}’
展开全部
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-php有如下三个要求:
1.PHP的版本在5.3.9以上,我用的是PHP5.3.23
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询