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%

相关推荐
2501_941404315 小时前
绿色科技与可持续发展:科技如何推动环境保护与资源管理
大数据·人工智能
swanwei5 小时前
量子科技对核心产业的颠覆性影响及落地时间表(全文2500字)
大数据·网络·人工智能·程序人生·量子计算
2501_941146709 小时前
5G与物联网:智能城市的未来
elasticsearch
isNotNullX9 小时前
数据中台有什么用?数据仓库和数据中台怎么选?
大数据·数据仓库·人工智能·数据中台
roman_日积跬步-终至千里10 小时前
【AI Engineering】Should I build this AI application?—AI应用决策框架与实践指南
大数据·人工智能
DolphinScheduler社区10 小时前
图解 Apache DolphinScheduler 如何配置飞书告警
java·大数据·开源·飞书·告警·任务调度·海豚调度
稚辉君.MCA_P8_Java10 小时前
通义千问 SpringBoot 性能优化全景设计(面向 Java 开发者)
大数据·hadoop·spring boot·分布式·架构
SeaTunnel11 小时前
Apache SeaTunnel 如何将 CDC 数据流转换为 Append-Only 模式?
大数据·开源·apache·开发者·seatunnel·转换插件
万山y11 小时前
git remote add做了什么
大数据·git·elasticsearch
六边形架构11 小时前
别再盲目地堆砌技术了!大部份大数据项目的失败,都是因为架构设计没做对!
大数据·系统架构