Tag - elasticsearch

elasticsearch 全文检索 跨域 cors    2017-07-19 20:47:25    862
参考官方doc地址:https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-http.html



添加如下配置:
 http.cors.enabled: true
 http.cors.allow-origin: /http?:\/\/192.168.10.139(:[0-9]+)?/

http.cors.enabled 开启跨域访问支持,默认为false
http.cors.allow-origin 跨域访问允许的域名地址,以上使用正则,域名这里我替换了IP


重启下服务即可


 

by 刘迎光@萤火虫工作室 
OpenBI交流群:495266201 
MicroService 微服务交流群:217722918 
mail: liuyg#liuyingguang.cn 
博主首页(==防止爬虫==):http://blog.liuyingguang.cn

elasticsearch 全文检索    2017-07-19 20:46:15    1068

为了学习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 restful    2017-07-19 20:41:59    925
为了学习elasticsearch,跟着官方文档及网上例子操作了一些,整理记录下来,以供大家参考。
本文所用测试工具:火狐插件HttpRequester。
elasticsearch:2.3

----------------------------------------创建文章---------------------------------------------
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 全文检索 中文分词    2017-07-19 20:36:23    794
最近用到elasticsearch做全文检索知识库系统,系统已经大致开发完成,需要中文分词,故网上搜索了下配置方法,可尝试几个都不可用,然后就看IK的git源码中有介绍,试了下,相比其他方法简单很多,也有效,故记录下,以供大家参考

参考文章:
    http://blog.csdn.net/liuzhenfeng/article/details/39404435
    https://github.com/medcl/elasticsearch-analysis-ik

Versions

IK versionES version
master2.3.1 -> master
1.9.32.3.3
1.9.02.3.0
1.8.12.2.1
1.7.02.1.1
1.5.02.0.0
1.2.61.0.0
1.2.50.90.x
1.1.30.20.x
1.0.00.16.2 -> 0.19.0

由于版本限制,并且我这里使用的是elascic 2.3.3,所以需要使用IK 1.9.3
1、下载源码:
    https://github.com/medcl/elasticsearch-analysis-ik.git
    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>
elasticsearch docker    2017-07-19 20:34:47    811

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}][%
1/2