Skip to content

ES 学习 #133

Description

@Draymonders

简介

es 底层基于 Lucene 实现分布式检索, Lucene主要是做分词处理(有各种分词器)

https://www.elastic.co/guide/cn/elasticsearch/guide/current/foreword_id.html

索引

创建索引

如下创建blog的索引

PUT blog
{
  "settings": {
    "number_of_replicas": 1,
    "number_of_shards": 2
  }
}

查看索引的配置

GET blog/_settings

文档

新建文档

PUT blog/_create/1
{
  "id": 1,
  "title": "just a title",
  "create-time": "2021-05-16",
  "content": "测试es新建文档"
}

查看文档

GET blog/_doc/1

检索

全文检索,按照相关性倒序排列

GET blog/_search 
{
  "query": {
    "match": {
      "title": "just"
    }
  }  
}

高亮操作

GET blog/_search 
{
  "query": {
    "match_phrase_prefix": {
      "title": "just"
    }
  },
  "highlight": {
    "fields": {
      "title": {}
    }
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions