Elasticsearch安装部署

Elasticsearch安装部署

1.下载elasticsearch安装包:Elasticsearch 2.4.6 | Elastic 

     

  下载中文分词器:Release v1.10.6 · medcl/elasticsearch-analysis-ik · GitHub

     

2.安装elasticsearch

rpm -ivh elasticsearch-2.4.6.rpm

3.安装中文分词器插件

   首先在elasticsearch安装目录下的 /plugins/下创建目录ik,然后copy elasticsearch-analysis-ik-1.10.6.zip的解压内容到ik目录        下,如下图:

   

 4.测试

#启动服务
service elasticsearch start  
#测试是否安装成功
curl  -XGET 'localhost:9200'

    结果如下,则安装成功

{
  "name" : "Wrecker",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "uwqbAklAQdSWWid84430Tg",
  "version" : {
    "number" : "2.4.6",
    "build_hash" : "5376dca9f70f3abef96a77f4bb22720ace3340fd",
    "build_timestamp" : "2017-07-18T12:17:44Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.4"
  },
  "tagline" : "You Know, for Search"
}

     测试中文分词

#创建index索引
curl -XPUT http://localhost:9200/index  
#定义文档的字段,主要是指定使用IK插件
curl -XPOST http://localhost:9200/index/test/_mapping -d'
{
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_max_word"
            }
        }
}'

#添加测试数据 
curl -XPOST http://localhost:9200/index/test/1 -d'
{"content":"浪费精力零零九零克己复礼"}'

  查询

#查询
curl -XPOST http://localhost:9200/index/test/_search?pretty  -d'
{
    "query" : { "match" : { "content" : "浪费" }},
}'

 查询结果如下则安装成功

  

{
  "took" : 13,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.35355338,
    "hits" : [ {
      "_index" : "index",
      "_type" : "test",
      "_id" : "1",
      "_score" : 0.35355338,
      "_source" : {
        "content" : "浪费精力零零九零克己复礼"
      }
    } ]
  }
}

   

相关推荐

  1. elasticsearch6.8.11安装部署开启用户密码访问

    2023-12-20 09:36:03       47 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-20 09:36:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-20 09:36:03       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-20 09:36:03       87 阅读
  4. Python语言-面向对象

    2023-12-20 09:36:03       96 阅读

热门阅读

  1. Spring Boot重试调用第三方API

    2023-12-20 09:36:03       56 阅读
  2. 力扣376周赛

    2023-12-20 09:36:03       55 阅读
  3. WebRTC编译记录

    2023-12-20 09:36:03       57 阅读
  4. 大数据分析岗是干什么的?

    2023-12-20 09:36:03       53 阅读
  5. 微信小程序map组件如何使用?

    2023-12-20 09:36:03       59 阅读
  6. JWT详解

    JWT详解

    2023-12-20 09:36:03      41 阅读
  7. 【Jenkins】Pipeline 语法解析(声明式Pipeline)

    2023-12-20 09:36:03       56 阅读
  8. MyBatis ${}和#{}区别

    2023-12-20 09:36:03       59 阅读
  9. ax650使用ax-pipeline进行推理

    2023-12-20 09:36:03       55 阅读