添加如下配置:
http.cors.enabled: true
http.cors.allow-origin: /http?:\/\/192.168.10.139(:[0-9]+)?/
http.cors.enabled 开启跨域访问支持,默认为false
http.cors.allow-origin 跨域访问允许的域名地址,以上使用正则,域名这里我替换了IP
重启下服务即可
为了学习elasticsearch,跟着官方文档及网上例子操作了一些,整理记录下来,以供大家参考。
本文所用测试工具:火狐插件HttpRequester。
elasticsearch:2.3
----------------------------------------创建index---------------------------------------------
Content-Type: application/json
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 21
{"acknowledged":true}
----------------------------------------查询index---------------------------------------------
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 361
{
"megacorp1" : {
"aliases" : { },
"mappings" : { },
"settings" : {
"index" : {
"creation_date" : "1467844960627",
"number_of_shards" : "5",
"number_of_replicas" : "1",
"uuid" : "3luuvHNGSf2RBYJHxRGUNg",
"version" : {
"created" : "2030399"
}
}
},
"warmers" : { }
}
}
----------------------------------------创建type--------------------
为了学习elasticsearch,跟着官方文档及网上例子操作了一些,整理记录下来,以供大家参考。
本文所用测试工具:火狐插件HttpRequester。
----------------------------------------创建文章---------------------------------------------
Content-Type: application/json
{
"first_name" : "John",
"last_name" : "Smith",
"age" : 25,
"about" : "I love to go rock climbing",
"interests": [ "sports", "music" ]
}
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 127
{"_index":"megacorp","_type":"employee","_id":"1","_version":6,"_shards":{"total":2,"successful":1,"failed":0},"created":false}
----------------------------------------查询文章---------------------------------------------
-- response --
200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 278
{
"_index" : "megacorp",
"_type" : "employee",
"_id" : "1",
"_version" : 6,
"found" : true,
"_source" : {
"first_name
最近用到elasticsearch做全文检索知识库系统,系统已经大致开发完成,需要中文分词,故网上搜索了下配置方法,可尝试几个都不可用,然后就看IK的git源码中有介绍,试了下,相比其他方法简单很多,也有效,故记录下,以供大家参考
参考文章:
Versions
IK version | ES version |
---|
master | 2.3.1 -> master |
1.9.3 | 2.3.3 |
1.9.0 | 2.3.0 |
1.8.1 | 2.2.1 |
1.7.0 | 2.1.1 |
1.5.0 | 2.0.0 |
1.2.6 | 1.0.0 |
1.2.5 | 0.90.x |
1.1.3 | 0.20.x |
1.0.0 | 0.16.2 -> 0.19.0 |
由于版本限制,并且我这里使用的是elascic 2.3.3,所以需要使用IK 1.9.3
1、下载源码:
tag:v1.9.3
2、构建 ik
修改pom.xml中repositories的配置(原有地址太慢,不确定是否可以,所以切换到自己的仓库中)
<repository> <id>mine</id> <name>public Releases</name> <layout>default</layout> </repository> <repository> <id>mine-meteorite-bi-release</id> <name>public Releases</name> <layout>default</layout> |
1、下载镜像:
docker pull index.docker.io/library/elasticsearch:2.3.3
2、修改配置文件:
分别创建目录:
/usr/share/elasticsearch/config
/usr/share/elasticsearch/data
config目录中创建文件:elasticsearch.yml ,内容如下:
-------------------------------------------------- elasticsearch.yml内容 -------------------------------------------------
network.host: 192.168.10.136
-------------------------------------------------- elasticsearch.yml内容 -------------------------------------------------
config目录中创建文件:logging.yml,内容入下
-------------------------------------------------- logging.yml内容 ------------------------------------------------------
# you can override this using by setting a system property, for example -Des.logger.level=DEBUG
es.logger.level: INFO
rootLogger: ${es.logger.level}, console
logger:
# log action execution errors for easier debugging
action: DEBUG
# reduce the logging for aws, too much is logged under the default INFO
com.amazonaws: WARN
appender:
console:
type: console
layout:
type: consolePattern
conversionPattern: "[%d{ISO8601}][%