2018-8-25未命名文件
type(None) 16:35:39
elasticSearch解决大数据量字段模糊查询,建立数据索引库,全文检索方式查询。
全文检索:检索文本中的每个词与搜索项进行对此。
全文索引:采用分词器,对文本每个词进行切分,建立词条,方便进行查找。
Lucene 就是一套 全文检索编程API , 基于Lucene 对数据建立索引,进行查询
现在企业开发中,更常用是的 solr 搜索服务器和 ElasticSearch 搜索服务器
1.索引对象: 存储数据的表结构 ,任何搜索数据,存放在索引对象上
2.映射:数据如何存放到索引对象上,需要有一个映射配置, 数据类型、是否存储、是否分词
3.文档: 一条数据记录, 存在索引对象上
4.文档类型: 一个索引对象 存放多种类型数据,数据用文档类型进行标识
ElasticSearch有什么优点呢?
1 分布式实时文件存储,可将每一个字段存入索引,使其可以被检索到。?
2 实时分析的分布式搜索引擎。?
分布式:索引分拆成多个分片,每个分片可有零个或多个副本。集群中的每个数据节点都可承载一个或多个分片,并且协调和处理各种操作;?
负载再平衡和路由在大多数情况下自动完成。?
3 可以扩展到上百台服务器,处理PB级别的结构化或非结构化数据。也可以运行在单台PC上(已测试)?
支持插件机制,分词插件、同步插件、Hadoop插件、可视化插件等。
select * from students where name != "周杰伦";
select * from students where is_delete=0;
select * from students where id > 3 and gender = 0;
select * from student where name like "黄%";
select * from students where id between 3 and 8;
select * from students where height is null;
select * from students order by id desc;
select * from students where gender=1 order by id asc;
select * from students order by height desc, id asc;
select count(*) from students;
sel
select max(height) from students;
select sum(age) from students;
select avg(age) from students;
select sum(age) from students where gender = 1;
select avg(age) from students where gender = 1;
select sum(age)/count(*) from students;
select sum(age)/count(*) from students where gender = 1;
select gender from students group by gender;
select gender,group_concat(name) from students group by gender;
select gender,group_concat(name) from students group by gender;
select gender,avg(age) from students group by gender;
select gender,count(*) from students group by gender;
select gender,count() from students group by gender having count() > 2;
select gender,count(*) from students group by gender having gender = "男";
select gender,count(*) from students group by gender with rollup;
select gender,count(*),sum(age) from students group by gender with rollup;
select gender,group_concat(age) from students group by gender with rollup;
select * from students limit 0,4;
select * from students limit 2,2;
select * from students inner join classes on students.cls_id = classes.id;
select * from students inner join classes on students.cls_id = classes.id;
select * from students as s inner join classes as c on s.cls_id = c.id;
select * from students as s left join classes as c on s.cls_id = c.id;
select * from students as s right join classes c on s.cls_id = c.id;
select * from students order by id desc limt 0,2;
select * from students where age > (select avg(age) from students) ;
select * from students where age > (select avg(age) from students);
select * from classes where id in (select cls_id from students);
select * from students where (age,height) = (select max(age),max(height) from students);
select distinct gender from students;
select gender ,count(*) from students group by gender;
select gender,group_concat(name) from students group by gender;
select cls_id,group_concat(name) from students group by cls_id;
select * from students order by id desc;
select gender,count() from students group by gender having count() >2;
select gender,count(*) from students group by gender with rollup;
select * from students order by id desc limit 0,10;
select * from students inner join classes on students.cls_id = classes.id;
select students.name,classes.name from students inner join classes on students.cls_id = classes.id;
select students.name as a,classes.name as b from students inner join classes on students.cls_id = classes.id;
select * from students as s left join classes as c on s.cls_id = c.id;
select * from students as s right join classes as c on s.cls_id = c.id;
create table booktest_areainfo(
aid int primary key,
atitle varchar(20),
pid int
);
select count(*) from booktest_areainfo where pid is null;
select atitle from booktest_areainfo where pid is null;
select city.* from booktest_areainfo as city inner join booktest_areainfo as province on city.pid = province.aid where province.atitle="湖北省";
数据库商品类表格的设计开发,
1,Django_Contab实现网站首页静态化页面的定时更新;
2,Redis数据库缓存高频数据,加快网站的响应速度;
3,账号(用户名,电话号) + 密码模式实现切换登录,QQ,微信,微博等第三方登录方式的引入,实现用户多渠道登录实现;
4,Celery搭配Admin站点类实现详情页面的后台数据变动实时同步更新详情静态化页面;
5,基于COOKIE和Redis对传统购物车的优化,未登录用户购物车数据暂存COOKIEs,登录后同步数据到Redis中,提高用户购物体验;
6,订单模块的开发,Django中的Atomic来控制订单模块数据库事务的执行,乐观锁防止高并发下的超卖现象;
7,Docker来部署FastDFS,重载Django原生的文件管理类,将FastDFS融入到项目中,实现海量文件的存储;
8,sql数据库双机热备,主从配置实现读写分离,提高数据库性能;
9,Celery开启进程订阅redis数据过期信号,并相应的操作数据库进行库存的增加;
10,X-admin来搭建后台站点管理,实现用户权限管理;