技术:elasticsearch5.5
运行环境:mac10.12 + postman
demo功能:提供基本的rest 操作, 比如网上都说curl 啥的, 对比mysql查询
1. 安装过程google,
2. 初始化数据工具:http://git.oschina.net/youlixishi/demo-world/tree/master/src/elasticsearch.data.builder
3. 如果想可视化管理es,请google安装elasticsearch-head
4. 索引名字=demo_index_like_db, 索引type=demo_type_like_table
sql=select * from tablename order by id asc limit 10 offset 0;
method=post
url=http://localhost:9200/demo_index_like_db/demo_type_like_table/_search
body=
{
"query": {
"match_all" : {//查询全部数据
}
},
"size": 10,//每页10条
"from":0,//offset
"sort": { "id": { "order": "asc" } }//id从小到大排序
}
sql=select * from tablename where userName="鞠雨泽" order by id asc limit 10 offset 0;
method=post
url=http://localhost:9200/demo_index_like_db/demo_type_like_table/_search
body=
{
"query": {
"match" : {
"id":190053
}
},
"size": 10,
"from":0,
"sort": { "id": { "order": "asc" } }
}
{
"query": {
"match_phrase_prefix" : {
"content":"利哲"
}
},
"size": 10,
"from":0,
"sort": { "id": { "order": "asc" } }
}
sql=
method=get
url=localhost:9200/demo_index_like_db/demo_type_like_table/_search?q="蓬昊"&size=2&from=0
sql=select * from tablename where shopId=1019 and userId=253 order by id asc limit 10 offset 0
method=post
url=http://localhost:9200/demo_index_like_db/demo_type_like_table/_search
body=
{
"query": {
"bool": {
"must": [//must=&&,should=||,must_not=!must
{
"match": {
"shopId": 1019
}
},
{
"match": {
"userId": 253
}
}
]
}
},
"size": 10,
"from": 0,
"sort": {
"id": {
"order": "asc"
}
}
}
sql=select * from tablename where id>=1 and id<=9999999 order by id asc limit 10 offset 0
method=post
url=http://localhost:9200/demo_index_like_db/demo_type_like_table/_search
body=
{
"query": {
"filtered": {
"query": {
"match_all": {}//这里可以设各种查询条件
},
"filter": {
"range": {
"id": {
"gte": 1,
"lte": 9999999
}
}
}
}
},
"size": 10,
"from": 0,
"sort": {
"id": {
"order": "asc"
}
}
}
sql=select * from tablename group by userId order by id asc limit 10 offset 0
method=post
url=http://localhost:9200/demo_index_like_db/demo_type_like_table/_search
body=
{
"aggs": {
"group_by_userId": {//这里
"terms": {
"field": "userId"//这里
}
}
},
"size": 2,
"from":0,
"sort": { "id": { "order": "asc" } }
}
分片计算=
shard = hash(routing) % number_of_primary_shards
欢迎添加微信,互相学习↑↑↑ -_-
白老虎
programming is not only to solve problems, ways to think
grafana 级连 菜单 templating (variables) 配置
rocketmq 集群搭建 (2master + 2slave + 2namesrv)
AI 机器人 抓取 微信 聊天中的 百度网盘 分享地址和密码