ETJava Beta | Java    注册   登录
  • elasticsearch 中文分词 - 查询中文分词   查询时需要指定索引名称,索引类型 同时还要指定分词器 smartcn   package com.et.index; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common
    发表于 2024-04-09 22:23:44 阅读(215)
  • elasticsearch 中文分词 - smartcn插件安装 elasticsearch默认分词器针对中文分词比较坑,直接分词成单个汉字 elasticsearch官方推荐使用smartcn插件 另外 如果灵活度较高的话 可以使用IK 这里我们重点搞下smartcn先 安装smartcn插件 elasticsearch中使用中文分析 需要单独安装插件 直接在服务器进行安装即可 程序中无需额外引入 安装步骤: 1. 直接用 elasticsearch的bin目录下的plugin命令安装即可 先进入elasticsearch的bin目录 执行 sh elasticsearch-
    发表于 2024-04-09 22:21:43 阅读(181)
  • elasticsearch 多条件查询 - filter过滤 过滤查询 例如 票价必须少于40 方式1 restful api filter表示过滤 range 表示范围查询 let 表示小于 get 大于 POST http://192.168.199.126:9200/film/dongzuo/_search/ { "query": { "bool": { "must": { "match": { "title": "战" } }, "filter": {
    发表于 2024-04-09 22:15:51 阅读(186)
  • elasticsearch 多条件查询 - 权重查询  根据得分查询 should 使用得分之前 POST http://192.168.199.126:9200/film/dongzuo/_search/ { "query": { "bool": { "must": [ { "match": { "title": "战" } } ] } } } 使用得分之后 should POST http://192.168.199.126:9200
    发表于 2024-04-09 22:12:26 阅读(199)
  •  elasticsearch 多条件查询 - 不包含关键字查询 must_not 方式1 restful api 不包含指定关键字 使用 must_not POST http://192.168.199.126:9200/film/dongzuo/_search/ { "query": { "bool": { "must": { "match": { "title": "战" } }, "must_not": { "match": { "con
    发表于 2024-04-09 22:11:33 阅读(195)
  • elasticsearch 多条件查询 must 实际开发中,基本都是组合多条件查询 elasticsearch使用bool来实现这种需求 主要参数: must 文档 必须 匹配这些条件才能被包含进来。 must_not 文档 必须不 匹配这些条件才能被包含进来。 should 如果满足这些语句中的任意语句,将增加 _score ,否则,无任何影响。它们主要用于修正每个文档的相关性得分。 filter 必须 匹配,但它以不评分、过滤模式来进行。这些语句对评分没有贡献,只是根据过滤标准来排除或包含文档。
    发表于 2024-04-09 22:04:43 阅读(198)
  • elasticsearch 查询 - 查询条件高亮显示 方式1 restful api POST http://192.168.199.126:9200/film/dongzuo/_search/ { "query": { "match": { "title": "星球" } }, "_source": { "include": [ "title", "price" ] }, "highlight": { "fields": { "title": {} } } }
    发表于 2024-04-09 21:59:50 阅读(206)
  • elasticsearch 查询 - 简单条件查询 方式1 restful api POST http://192.168.199.126:9200/film/dongzuo/_search/ { "query": { "match": { "title": "星球" } } } 方式2 Java接口实现 private TransportClient client; private static String host="192.168.199.126"; private static int port=9300; //
    发表于 2024-04-09 21:58:09 阅读(203)
  • elasticsearch 查询 - 过滤数据列 过滤数据列指的是只查询需要的列 例如 title,content,price等 方式1 restful api POST http://192.168.199.126:9200/film/dongzuo/_search/ { "from": 0, "size": 2, "_source": { "include": [ "title", "price" ] } } 方式2 Java接口实现 private TransportClient client;
    发表于 2024-04-09 21:56:28 阅读(212)
  • elasticsearch 查询 - 排序 方式1 restful api POST http://192.168.199.126:9200/film/dongzuo/_search/ { "sort": [ { "publishDate": { "order": "desc" } } ] } 多字段排序 { "sort": [ { "publishDate": { "order": "desc" } }, { "price": {
    发表于 2024-04-09 21:54:02 阅读(190)