1. 安装:

https://www.elastic.co/downloads/elasticsearch

  1. 下载安装包后解压

配置elastaticsearch.yml:

# ======================== Elasticsearch Configuration =========================

#

# NOTE: Elasticsearch comes with reasonable defaults for most settings.

#       Before you set out to tweak and tune the configuration, make sure you

#       understand what are you trying to accomplish and the consequences.

#

# The primary way of configuring a node is via this file. This template lists

# the most important settings you may want to configure for a production cluster.

#

# Please consult the documentation for further information on configuration options:

# https://www.elastic.co/guide/en/elasticsearch/reference/index.html

#

# ---------------------------------- Cluster -----------------------------------

#

# Use a descriptive name for your cluster:

#

#cluster.name: my-application

#

# ------------------------------------ Node ------------------------------------

#

# Use a descriptive name for the node:

#

#node.name: node-1

#

# Add custom attributes to the node:

#

#node.attr.rack: r1

#

# ----------------------------------- Paths ------------------------------------

#

# Path to directory where to store the data (separate multiple locations by comma):

#

#path.data: /path/to/data

#

# Path to log files:

#

#path.logs: /path/to/logs

#

# ----------------------------------- Memory -----------------------------------

#

# Lock the memory on startup:

#

#bootstrap.memory_lock: true

#

# Make sure that the heap size is set to about half the memory available

# on the system and that the owner of the process is allowed to use this

# limit.

#

# Elasticsearch performs poorly when the system is swapping the memory.

#

# ---------------------------------- Network -----------------------------------

#

# By default Elasticsearch is only accessible on localhost. Set a different

# address here to expose this node on the network:

#

#network.host: 192.168.0.1

#

# By default Elasticsearch listens for HTTP traffic on the first free port it

# finds starting at 9200. Set a specific HTTP port here:

#

http.port: 9200

#

# For more information, consult the network module documentation.

#

# --------------------------------- Discovery ----------------------------------

#

# Pass an initial list of hosts to perform discovery when this node is started:

# The default list of hosts is ["127.0.0.1", "[::1]"]

#

#discovery.seed_hosts: ["host1", "host2"]

#

# Bootstrap the cluster using an initial set of master-eligible nodes:

#

#cluster.initial_master_nodes: ["node-1", "node-2"]

#

# For more information, consult the discovery and cluster formation module documentation.

#

# --------------------------------- Readiness ----------------------------------

#

# Enable an unauthenticated TCP readiness endpoint on localhost

#

#readiness.port: 9399

#

# ---------------------------------- Various -----------------------------------

#

# Allow wildcard deletion of indices:

#

#action.destructive_requires_name: false

http.cors.enabled: true

http.cors.allow-origin: "*"

#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------

#

# The following settings, TLS certificates, and keys have been automatically

# generated to configure Elasticsearch security features on 15-07-2022 05:45:57

#

# --------------------------------------------------------------------------------

# Enable security features

xpack.security.enabled: false

xpack.security.enrollment.enabled: true

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents

xpack.security.http.ssl:

enabled: true

keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes

xpack.security.transport.ssl:

enabled: true

verification_mode: certificate

keystore.path: certs/transport.p12

truststore.path: certs/transport.p12

# Create a new cluster with the current node only

# Additional nodes can still join the cluster later

# Allow HTTP API connections from anywhere

# Connections are encrypted and require user authentication

http.host: 127.0.0.1

# Allow other nodes to join the cluster from anywhere

# Connections are encrypted and mutually authenticated

#transport.host: 0.0.0.0

#----------------------- END SECURITY AUTO CONFIGURATION -------------------------

action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*

xpack.graph.enabled: false

xpack.ml.enabled: false

3.进入bin目录下,双击执行elasticsearch.bat

4.看到started说明启动成功,打开浏览器测试一下,如下图

http://localhost:9200

3、安装ElasticSearch-head插件

下载插件

GitHub - mobz/elasticsearch-head: A web front end for an elastic search cluster下载安装包

本地安装node环境,下载安装包解压后执行npm install;  npm run start 即可;下载插件时如果插件版本过低可以用如下配置替换:

{
  "name": "elasticsearch-head",
  "version": "0.0.0",
  "description": "Front end for an elasticsearch cluster",
  "main": "_site/index.html",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "start": "grunt server",
    "test": "grunt jasmine",
    "proxy": "node proxy/index.js"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/mobz/elasticsearch-head.git"
  },
  "author": "",
  "license": "Apache2",
  "gitHead": "0c2ac0b5723b493e4454baa7398f386ecb829412",
  "readmeFilename": "README.textile",
  "devDependencies": {
    "grunt": "1.5.3",
    "grunt-contrib-clean": "1.0.0",
    "grunt-contrib-concat": "1.0.1",
    "grunt-contrib-connect": "3.0.0",
    "grunt-contrib-copy": "1.0.0",
    "grunt-contrib-jasmine": "1.0.3",
    "grunt-contrib-watch": "1.1.0",
    "grunt-karma": "2.0.0",
    "http-proxy": "1.16.x",
    "karma": "1.3.0"
  },
  "dependencies": {
    "extend": "^3.0.2"
  }
}

启动后访问 127.0.0.1:9100即可;

这个插件是elastaticsearch的图形化操作页面

  1. springboot集成:

pom文件加入:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>

Application.yml 配置es地址及连接:没有设置账号密码,但是可以设置

spring:
  elasticsearch:
    rest:
      uris: http://127.0.0.1:9200

定义实体,映射es上的索引:es上需要建立名为accounts的索引,并插入数据,通过head可视化界面操作即可:

http://localhost:9200/accounts    put请求

{
    "mappings": {
        "properties": {
            "user": {
                "type": "text"
            },
            "title": {
                "type": "text"=
            },
            "desc": {
                "type": "text"
            }
        }
    }
}

http://localhost:9200/accounts/_doc/  post请求

{"user":"123","title":"123","desc":"123"}

@Data
@Document(indexName = "accounts") //es上索引名称
public class Accounts {

@Field(type = FieldType.Text)
    private String user;

@Field(type = FieldType.Text,analyzer = "ik_max_word") //字段类型,采用中文分词器
    private String title;

@Field(type = FieldType.Text)
    private String desc;
}

Service方法,实现es查询,采用ElasticsearchRestTemplate模板

public void test() {
        //根据id查询
        //Accounts accounts = restTemplate.get("Rnu1AIIBd4eRv-x8LdUX", Accounts.class);

//根据条件查询
        BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
        //精确查询
//        queryBuilder.must(QueryBuilders.termQuery("title", "1"));
        //模糊查询
//        queryBuilder.must(QueryBuilders.wildcardQuery("title", "*1*"));
        //中文分词查询,查询什么:查询,什么
        queryBuilder.must(QueryBuilders.matchQuery("title", "查询什么"));
        NativeSearchQuery query = new NativeSearchQueryBuilder().withQuery(queryBuilder).build();
        SearchHits<Accounts> search = restTemplate.search(query, Accounts.class);
        List<SearchHit<Accounts>> searchHits = search.getSearchHits();
        List<Accounts> collect = searchHits.stream().map(SearchHit::getContent).collect(Collectors.toList());
        Accounts content = searchHits.get(0).getContent();
        log.info(""+content);
        System.out.println("");
    }

搜索引擎ElastaticSearch使用相关推荐

  1. 电子设计搜索引擎引入分析和见解

    电子设计搜索引擎引入分析和见解 Electronics Design Search Engine Introduces Analytics and Insights 2020年上半年最受欢迎的组件是什 ...

  2. 搜索引擎ElasticSearchV5.4.2系列二之ElasticSearchV5.4.2+kibanaV5.4.2+x-packV5.4.2安装

    相关博文: 搜索引擎ElasticSearchV5.4.2系列一之ES介绍 搜索引擎ElasticSearchV5.4.2系列二之ElasticSearchV5.4.2+klanaV5.4.2+x-p ...

  3. 搜索引擎优化培训教程

    很详细的搜索引擎优化培训教材 View more presentations from mysqlops 转载于:https://www.cnblogs.com/macleanoracle/archi ...

  4. 蜘蛛搜索引擎_各大搜索引擎的蜘蛛特点

    我们在做SEO时,需要对各个搜索引擎的爬行蜘蛛有一个很好的了解认知,才能更好的去做好SEO优化,就如你要去谈业务,各大客户的一些身份信息需要了解一样. 下面每日学点SEO就给大家整理了各大搜索引擎蜘蛛 ...

  5. php常用的搜索引擎,常用搜索引擎高级命令有哪些

    一些常用的高级搜索引擎命令,包括以下: 1.Site 这个是最常见的高级搜索命令,作用是查询网站的收录情况,并且这个命令在所有的搜索引擎里是通用的.用法:site:www.aizhan.com 2.D ...

  6. 百度搜索引擎广告SEM调用架构示意图

    下面是从百度计算广告学教程的一份ppt中摘取的几张图片,它们清晰地给出了搜索引擎广告的投放流程,以便参考. 参考文献 [1].百度搜索广告系统工程架构.ppt

  7. 搜索引擎技术之概要预览

    搜索引擎技术之概要预览 前言 近些天在学校静心复习功课与梳理思路(找工作的事情暂缓),趁闲暇之际,常看有关搜索引擎相关技术类的文章,接触到不少此前未曾触碰到的诸多概念与技术,如爬虫,网页抓取,分词,索 ...

  8. 搜索引擎中的URL散列

    散列(hash)也就是哈希,是信息存储和查询所用的一项基本技术.在搜索引擎中网络爬虫在抓取网页时为了对网页进行有效地排重必须对URL进行散列,这样才能快速地排除已经抓取过的网页.最理想的状态是对联网上 ...

  9. ASP.NET 制作让搜索引擎可以友好访问的链接

    作者:http://www.donews.net/lealting/archive/2004/03/31/9759.aspx 今天看了一篇文章,主要是讲,如何制作让搜索引擎可以友好访问的链接,大概的内 ...

最新文章

  1. 【go】sdk + idea-plugin 开发工具安装
  2. 327 - Evaluating Simple C Expressions
  3. 函数调用的参数太少c语言,调用input_message的参数太少在主函数中 是神马意思 大神们帮帮我...
  4. keepalived安装与配置_Nginx_Keepalived高可用配置
  5. mysql行级锁升级_mysql innodb 行级锁升级
  6. 接口测试人员需要掌握的知识技能
  7. 通才还是专才——由摩托裁员引发的讨论
  8. 从别的网站摘抄的,挺有用的
  9. Databinding在自定义ViewGroup中如何绑定view
  10. 系统虚拟化与虚拟机的区别
  11. 海康ps流转换h264流
  12. FFMPEG实现RTSP中H264数据流解码 并且实时播放
  13. 共享图书横空出世一本书看十天只需一块钱
  14. kubernetes lowB安装方式
  15. 急!程序员夫妻结婚了,婚戒上刻什么字好?
  16. vyos-vyatta在ospf和bgp之间路由重发布使用 打tag形式进行路由过滤
  17. 深度linux安装宝塔,Linux 安装宝塔
  18. 啥子是volatile
  19. WIN10, USB转TTL驱动安装( CH340 和 PL- 2303 )
  20. 深度linux禁用独立显卡,deepin显卡设置

热门文章

  1. 动手学习深度学习-环境配置
  2. 奥威BI,适合中国电商的大数据分析平台
  3. 用python画apc图_Python开发GUI实战:图片转换素描画工具!
  4. 数学建模——公式编辑技巧
  5. 【教程】摆脱UART,仅用JLink也能实现printf功能!! /*更新scanf*/
  6. 2.【Sharding-JDBC】快速入门
  7. python 中的continue、else和break区别
  8. OSVR头部追踪数据格式及VRPN数据处理流程
  9. 【对比学习】CUT模型论文解读与NCE loss代码解析
  10. 电子计算机月初美妙的交响,江苏版二年级下学期语文期中测试试卷(8页)-原创力文档...