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"]  
}

二、下期预告

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

学习目标

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

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

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

相关推荐
serve the people11 小时前
Elasticsearch(3) show me some examples
大数据·elasticsearch·jenkins
是一个Bug12 小时前
Elasticsearch 保姆级入门:从“找文件”到“秒级搜索”
大数据·elasticsearch·搜索引擎
serve the people12 小时前
Elasticsearch(4) show me some more advanced content
大数据·elasticsearch·jenkins
fangdengfu1231 天前
ES分析系统各个服务日志占用量
java·前端·elasticsearch
兄台の请冷静1 天前
Linux 安装es
linux·elasticsearch·jenkins
java_cj1 天前
Elasticsearch索引管理完全指南:从基础API到ILM生命周期管理
大数据·后端·elasticsearch·性能优化
Shawn Dev1 天前
团队协作中的 Git Tag 最佳实践:从入门到精通
大数据·git·elasticsearch
Dontla2 天前
.gitkeep文件作用(让Git追踪空目录,使该目录能被纳入版本控制)!.gitkeep
大数据·git·elasticsearch
INFINI Labs2 天前
Elasticsearch 6/7/8 到 Easysearch 2.x 迁移指南
大数据·elasticsearch·mybatis·向量·snapshot
_codemonster2 天前
Git 最常用操作和原理
大数据·git·elasticsearch