3 Star 8 Fork 3

Role / EasyElasticSearch

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

综述

github文档地址
gitee文档地址

Elasticsearch 是一个分布式、高扩展、高实时的搜索与数据分析引擎。它能很方便的使大量数据具有搜索、分析和探索的能力,简称ES


欢迎使用 EasyElasticSearch,它是一个操作ElasticSearch的基础类库。 支持表达式函数查询,别名操作 其中表达式解析参考了SqlSuger,特此感谢 !


1. 从零开始

1.1 Docker安装

  1. Step 1: 安装必要的一些系统工具

    sudo yum install -y yum-utils device-mapper-persistent-data lvm2

  2. Step 2: 添加软件源信息

    sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

  3. Step 3: 缓存并安装Docker-CE(可选)

    sudo yum makecache fast sudo yum -y install docker-ce

  4. Step 4: 开启Docker服务

    sudo service docker start

  5. Step 5: 设置Docker开机自启动

    systemctl enable docker

  6. Step 6: 启动Docker

    systemctl start docker

  7. Step 7: 查看版本

    docker --version

1.2 Docker-Compose 安装

  1. Step 1: 安装

    pip3 install docker-compose

  2. Step 2: 查看版本

    docker-compose version

1.3 ES 安装

elasticsearch.yml

## Default Elasticsearch configuration from Elasticsearch base image.
## https://github.com/elastic/elasticsearch/blob/master/distribution/docker/src/docker/config/elasticsearch.yml
#
cluster.name: "docker-cluster"
network.host: 0.0.0.0

## X-Pack settings
## see https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-xpack.html
#
xpack.license.self_generated.type: trial
xpack.security.enabled: false
xpack.monitoring.collection.enabled: false

docker-compose.yml

version: '3.2'

services:
  elasticsearch:
    restart: always
    image: elasticsearch:7.10.0
    volumes:
      - type: bind
        source: ./elasticsearch/config/elasticsearch.yml
        target: /usr/share/elasticsearch/config/elasticsearch.yml
        read_only: true
      - type: volume
        source: elasticsearch
        target: /usr/share/elasticsearch/data
    ports:
      - "9200:9200"
      - "9300:9300"
    environment:
      ES_JAVA_OPTS: "-Xmx256m -Xms256m"
      ELASTIC_PASSWORD: changeme
      # Use single node discovery in order to disable production mode and avoid bootstrap checks
      # see https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html
      discovery.type: single-node
networks:
  elk:
    driver: bridge

volumes:
  elasticsearch:

安装

`docker-compose up --build -d --force-recreate`

1.4 elasticsearch-head安装

安装谷歌插件, 解压缩安装,下载地址


2.简单使用

查询

 [HttpGet]
 public IActionResult Search()
 {
     var data = _searchProvider.Queryable<User>().Where(x => x.UserName == "52").ToList();
     return Ok(data);
 }

增加

 [HttpGet]
 public ActionResult Add()
 {
     var record = new RegistryRecord
     {
         UserId = "1268436794379079680",
         UserName = "es",
         RegistryTime = DateTime.Now
     };

     _indexProvider.Index<RegistryRecord>(record);
     return Ok("Success");
 }

 /// <summary>
 /// 批量新增
 /// </summary>
 /// <returns></returns>
 [HttpGet]
 public ActionResult BulkAdd()
 {     var records = new List<RegistryRecord>
     {
         new RegistryRecord{
               UserId = "1268436794379079680",
               UserName = "Bulkes1",
              RegistryTime = DateTime.Now
         },
         new RegistryRecord{
               UserId = "1268436794379079680",
               UserName = "Bulkes2",
              RegistryTime = DateTime.Now
         },
     };

     _indexProvider.BulkIndex<RegistryRecord>(records);
     return Ok("Success");
 }

删除

[HttpGet]
public IActionResult Delete()
{
    _deleteProvider.DeleteByQuery<RegistryRecord>(x => x.UserName == "Bulkes1");
    return Ok("Success");
}

.....

MIT License Copyright (c) 2020 Mc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一个操作ElasticSearch的基础类库。 支持表达式函数查询,拥有增删改查,别名操作等基础功能。简单易用。 展开 收起
C#
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/CRole/EasyElasticSearch.git
git@gitee.com:CRole/EasyElasticSearch.git
CRole
EasyElasticSearch
EasyElasticSearch
master

搜索帮助