ElasticSearch系列-3-java端整合CURD

文章目录

一、java端操作ES

整体代码见仓库:

https://gitee.com/YaChiXiaoLiao/es-java-cmh.git



客户端查询:

java 复制代码
# 三、Java 客户端整合

GET /productv4/_search
{
  "query": {
    "match_all": {}  
  }
}

GET /productv4/_mapping


GET /productv4/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "category": "平板电脑"  
          }
        }
      ]
    }
  },
  "sort": [  
    {
      "price": {
        "order": "desc"
      }
    }
  ],
  "from": 0,  
  "size": 10,  
  "_source": ["name", "price", "brand", "category"]  
}







GET /productv4/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "category": "智能手机"  
          }
        }
      ],
      "should": [  
        {
          "term": {
            "brand": "小米"
          }
        },
        {
          "term": {
            "brand": "华为"
          }
        }
      ],
      "must_not": [  
        {
          "term": {
            "price": 5999.0
          }
        }
      ],
      "filter": [  
        {
          "range": {
            "price": {
              "gt": 500
            }
          }
        }
      ]
    }
  },
  "sort": [  
    {
      "price": {
        "order": "desc"
      }
    }
  ],
  "from": 0,  
  "size": 10,  
  "_source": ["name", "price", "brand", "category"]  
}

二、下期预告

性能优化入门(解决实战中的性能瓶颈)

学习目标

理解分片与副本的核心概念,掌握合理的分片配置策略。

避免深度分页问题,掌握高效分页方案。

优化查询语句,提升检索性能。

相关推荐
vx-程序开发1 小时前
【计算机毕设】django校园跑腿服务系统83141
java·数据库·vue.js·spring boot·spring·elasticsearch·django
Elasticsearch2 小时前
jina-ocr-v1:在低成本 GPU 上实现更快速的文档解析
elasticsearch
深海鱼肝油ya4 小时前
向量数据库Elasticsearch(四)搜索文档——各种方式
人工智能·elasticsearch·向量数据库·es搜索文档·只能体·非结构化数据库
Elasticsearch8 小时前
SNAP 支付错误检测:Elastic 如何帮助美国各州应对 FY2028 的处罚
elasticsearch
Elastic 中国社区官方博客8 小时前
使用 Elasticsearch 和 Jina 进行 AI 视频搜索:精准找到你需要的视频片段秒数
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
Elasticsearch8 小时前
2026 年唯一获得满分 Endpoint Prevention and Response(EPR)评分的是 Elastic
elasticsearch
Elasticsearch1 天前
没有小到无法记录的日志文件:Elastic Agent 如何跟踪低于 1 KiB 阈值的文件
elasticsearch
Elasticsearch1 天前
使用 Elasticsearch 和 Jina 进行 AI 视频搜索:精准找到你需要的视频片段秒数
elasticsearch
Hrain-AI2 天前
AI 爬虫三档授权工程落地:搜索放行、训练拦截、Agent 分层(附脚本)
人工智能·elasticsearch·milvus
智搜广告2 天前
智搜广告:科技行业AI回答优化公司如何破局
大数据·python·elasticsearch·geo