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%

相关推荐
talen_hx29611 分钟前
《零基础入门Spark》学习笔记 Day 14
大数据·笔记·学习·spark
老纪的技术唠嗑局19 分钟前
告别OpenClaw配置丢失——Mindkeeper内测版邀测
大数据·elasticsearch·搜索引擎
老陈头聊SEO19 分钟前
高效整合长尾关键词以提升网站SEO排名的有效策略
其他·搜索引擎·seo优化
2501_9333295521 分钟前
技术深度剖析:Infoseek 字节探索舆情处置系统的全链路架构与核心实现
大数据·数据仓库·人工智能·自然语言处理·架构
key_3_feng22 分钟前
揭秘AI的“语言积木“:Token科普之旅
人工智能·搜索引擎·token
Elasticsearch24 分钟前
使用 Elasticsearch + Jina embeddings 进行无监督文档聚类
elasticsearch
intcube33 分钟前
让数据说话,让决策有据——构建闭环的数据驱动运营体系
大数据·人工智能·全面预算管理·财务规划
财经资讯数据_灵砚智能1 小时前
基于全球经济类多源新闻的NLP情感分析与数据可视化(夜间-次晨)2026年4月9日
大数据·人工智能·信息可视化·自然语言处理·ai编程
Apache Flink1 小时前
Flink Agents 0.3 Roadmap 解读
大数据·flink
呆码科技2 小时前
数据驱动决策:商贸物流软件的数据分析与预测功能
大数据·人工智能