谷粒商城集成 elasticsearch

本文详细介绍了谷粒商城如何集成Elasticsearch,包括其基本概念、搜索原理、与Solr的区别,以及DSL语句的使用。还涵盖了数据库数据的批量导入、搜索功能的实现,涉及品牌过滤、分类过滤、价格区间等多种筛选条件。
摘要由CSDN通过智能技术生成

谷粒商城集成 elasticsearch

一、elasticsearch 基本概念

  • Elasticsearch (简称ES)是一个分布式、restful 风格的搜索和数据分析引擎
索引(indices) Databases 数据库
类型(type) Table 数据表 [7.x废弃]
文档(Document) Row 行
字段(Field) Columns 列
mapping映射 schema约束

二、elasticsearch 搜索原理

倒排索引

  • 步骤
    • 数据根据词条进行分词,同时记录文档索引位置
    • 将词条相同的数据化进行合并
    • 对词条进行排序
  • 过程
    • 先将搜索词语进行分词,分词后在倒排索引列表查询文档位置(docId),根据docId查询文档数据。

三、elasticsearch 与 Solr 的区别

elasticsearch Solr
开箱即用 安装略微复杂
自带分布式协调管理功能 利用 zookeeper 进行分布式管理
仅支持 JSON 格式的数据 支持多种格式的数据,比如JSON、XML、CSV
适用于新兴的实时搜索应用 传统搜索应用的有力解决方案

四、DSL 语句的基本使用

1. 索引库操作

  • 查看所有索引库:GET /_cat/indices?v
  • 查看一个索引库:GET/索引库名
  • 创建索引库:
			PUT /索引库名
			{
   
				"settings": {
   
					"number_of_shards": 3, # 主分片数
					"number_of_replicas": 2 # 副分片数
				}
			}

2. 映射操作

  • type 字段类型
  • index 是否索引:取决于是否以该字段进行搜索
  • store 是否存储:取决于搜索结果集中是否展示该字段,es中即使设置为false,依然存储,存储到_source。如果设置为true,会额外保存一份
  • analyzer:分词器,这里使用ik分词器:ik_max_word或者ik_smart
PUT
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
gulimall_pms 商品 drop table if exists pms_attr; drop table if exists pms_attr_attrgroup_relation; drop table if exists pms_attr_group; drop table if exists pms_brand; drop table if exists pms_category; drop table if exists pms_category_brand_relation; drop table if exists pms_comment_replay; drop table if exists pms_product_attr_value; drop table if exists pms_sku_images; drop table if exists pms_sku_info; drop table if exists pms_sku_sale_attr_value; drop table if exists pms_spu_comment; drop table if exists pms_spu_images; drop table if exists pms_spu_info; drop table if exists pms_spu_info_desc; /*==============================================================*/ /* Table: pms_attr */ /*==============================================================*/ create table pms_attr ( attr_id bigint not null auto_increment comment '属性id', attr_name char(30) comment '属性名', search_type tinyint comment '是否需要检索[0-不需要,1-需要]', icon varchar(255) comment '属性图标', value_select char(255) comment '可选值列表[用逗号分隔]', attr_type tinyint comment '属性类型[0-销售属性,1-基本属性,2-既是销售属性又是基本属性]', enable bigint comment '启用状态[0 - 禁用,1 - 启用]', catelog_id bigint comment '所属分类', show_desc tinyint comment '快速展示【是否展示在介绍上;0-否 1-是】,在sku中仍然可以调整', primary key (attr_id) ); alter table pms_attr comment '商品属性'; /*==============================================================*/ /* Table: pms_attr_attrgroup_relation */ /*==============================================================*/ create table pms_attr_attrgroup_relation ( id bigint not null auto_increment comment 'id', attr_id bigint comment '属性id', attr_group_id bigint comment '属性分组id', attr_sort int comment '属性组内排序', primary key (id) ); alter table pms_attr_attrgroup_relation comment '属性&

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

三份强势七分暖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值