ElasticSearch与Sense插件的安装以及基本使用

ElasticSearch与Sense插件的安装以及基本使用

Elastic 的底层是开源库 Lucene。但是,没法直接用 Lucene,必须自己写代码去调用它的接口。Elastic 是 Lucene 的封装,提供了 REST API 的操作接口。
下载地址:
https://www.elastic.co/cn/downloads/elasticsearch
运行:elasticsearch.bat
在这里插入图片描述
浏览器打开http://localhost:9200
显示:

{
  "name" : "jOd1QPC",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "Y3uvSTWcTCyMu2navl2uzw",
  "version" : {
    "number" : "6.7.0",
    "build_flavor" : "default",
    "build_type" : "zip",
    "build_hash" : "8453f77",
    "build_date" : "2019-03-21T15:32:29.844721Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

elasticsearch官方文档:https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-index.html

Context Sense Chrome插件下载与安装:http://www.cnplugins.com/search/context-sense/download.html
如果出现:Google已将 xxx 标记为恶意程序并阻止安装问题
见:https://www.cnblogs.com/cnjavahome/p/9124584.html
打开Sense插件如下:
在这里插入图片描述

  • 新建索引的时候老是出现问题:

{“error”:“Content-Type header [application/x-www-form-urlencoded] is not supported”,
“status”:406}
在这里插入图片描述

PUT /movies/movie/1
{
    "title": "The Godfather",
    "director": "Francis Ford Coppola",
    "year": 1972
}
GET /movies/movie/1
DELETE /movies/movie/1

在这里插入图片描述

另外也可以使用Shell来尝试一下了,如下:

  • 新建索引
curl -XPUT "http://localhost:9200/movies/movie/1" -H 'Content-Type: application/json' -d'
{
    "title": "The Godfather",
    "director": "Francis Ford Coppola",
    "year": 1972
}'

在这里插入图片描述

  • 获取索引
curl -XGET "http://localhost:9200/movies/movie/1"  -H 'Content-Type: application/json' 

在这里插入图片描述

  • 删除索引
curl -XDELETE "http://localhost:9200/movies/movie/1"  -H 'Content-Type: application/json' 
删除后查看:curl -XGET "http://localhost:9200/movies/movie/1"  -H 'Content-Type: application/json'

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_41104835/article/details/88977228