elasticsearch (dsl)

正排索引 和 倒排索引

正排索引:通过id ,查询content

倒排索引:通过content,查询到符合的 ids

eg:

通过《静夜思》,找到整片文章。

通过"明月",找到《静夜思》 《望月怀古》《关山月》等

get 查询

索引的基本信息:

GET your_index/_mapping //跟看mysql表字段差不多

GET your_index/_alias //查看索引的别名

GET /_cat/health?v //查看集群状态

GET _cat/indices // 查看所有index

GET _cat/shards/your_index //查看指定索引的分片数,每个分片有主(p)副(r)分片

查询索引内容:

match_all:

复制代码
GET /you_index/_search
{
  "query":{
    "match_all": {}
}

bool

bool查询是一个非常强大且常用的复合查询,它允许你组合多个查询条件。bool 查询的核心概念包括以下四种子句:

  1. must : 子句必须匹配文档。类似于 SQL 中的 AND 操作符。
  2. filter : 子句必须匹配文档,但不影响评分。也就是说,它只过滤文档,但不参与评分计算。
  3. should : 子句可以匹配文档。如果在一个 bool 查询中包含了多个 should 子句,则至少一个 should 子句必须匹配文档。类似于 SQL 中的 OR 操作符。
  4. must_not: 子句不能匹配文档。类似于 SQL 中的 NOT 操作符。

eg:

复制代码
GET you_index/_search
{
  "query": {
        "bool": {
            "must": [
                {
                    "bool": {
                        "should": [
                            {
                                "term": {
                                    "name": {
                                        "value": "林俊凯",
                                        "boost": 1
                                    }
                                }
                            },
                            {
                                "term": {
                                    "zh_name": {
                                        "value": "林俊凯",
                                        "boost": 1
                                    }
                                }
                            }
                        ]
                    }
                },
                {
                    "bool": {
                        "should": [
                            {
                                "range": {
                                    "fans_num": {
                                        "gte": "800"
                                    }
                                }
                            },
                            {
                                "terms": {
                                    "tag": [
                                        1010,
                                        1013
                                    ]
                                }
                            }
                        ]
                    }
                }
            ]
        }
    },
    "sort": {
        "_score": {
            "order": "desc"
        },
        "score": {
            "order": "desc"
        }
    }
}

range

复制代码
    "range": {
            "fans_num": {
              "gte": 800,
              "lte":126334
            }
     }

term

terms

prefix

multi_match

multi_phrase

analyzer

mla

standard

keyword

slop

3<80%

相关推荐
嘉禾望岗50316 分钟前
Yarn介绍与HA搭建
大数据·hadoop·yarn
小麦矩阵系统永久免费30 分钟前
小麦矩阵系统:让短视频分发实现抖音快手小红书全覆盖
大数据·人工智能·矩阵
IT研究室1 小时前
大数据毕业设计选题推荐-基于大数据的国家药品采集药品数据可视化分析系统-Spark-Hadoop-Bigdata
大数据·hadoop·信息可视化·spark·毕业设计·数据可视化·bigdata
一刀到底2111 小时前
springboot3.3.5 集成elasticsearch8.12.2 ssl 通过 SSL bundle name 来实现
网络·elasticsearch·ssl·springboot3
Lx3522 小时前
Hadoop性能瓶颈分析:从JVM到磁盘IO的全链路优化
大数据·hadoop
Elasticsearch2 小时前
Elasticsearch:智能搜索的 MCP
elasticsearch
大数据点灯人2 小时前
【Flink】Flink Runtime 开发指南
大数据·flink
一个java开发2 小时前
distributed.client.Client 用户可调用函数分析
大数据·python
字节数据平台4 小时前
一客一策:Data Agent 如何重构大模型时代的智能营销
大数据·人工智能·重构
字节跳动数据平台4 小时前
《十六进制觉醒》:与我们一起,探索AI与数据的无限可能!
大数据