来到了倒数第二天
真是快被榨乾了呢(还真是没料 (┐「﹃゚。))
但说好写三十篇技术文就是要灌满三十天!!!
第一段参考文献
首先我们知道Lucene能够将字串直接拿来解析做查询
爲了方便再把之前的东西贴过来
gt: > 大於(greater than)
lt: < 小於(less than)
gte: >= 大於或等於(greater than or equal to)
lte: <= 小於或等於(less than or equal to )
那样的事情我们叫做
//关键词有以下
y-Years、M-Months、w-Weeks、d-Days、h-Hours、H-Hours、m-Minutes、s-Seconds
对范围搜所有三个可以共用的概念
1. Date Math
2. Date Math to round
3. 日期格式(依据预设日期格式与指定时区进行检索)
假设今天想要查询目前月整个月份,资料
gte就会查询大於等於的日期(经过四舍五入)
lte就会查询小於等於的日期(经过四舍五入)
假定 now 2020-10-13 (写的文章时间)
//Date Math
{
"query": {
"range" : {
"createAt" : {
//这样就会查询出十月後的资料
"gte" : "now/M",
}
}
}
}
//这样的话就等同於
//mysql:where createAt >= "2020-10-01 00:00:00"
//Date Math to round
{
"query": {
"range" : {
"createAt" : {
"gte" : "now-1d/d",
"lt" : "now/d"
}
}
}
}
//这样的话就等同於
//mysql:where createAt >= "2020-10-13 00:00:00" and createAt < "2020-10-14 00:00:00"
//日期格式
{
"query": {
"range" : {
"createAt" : {
"gte": "13/10/2020",
"lte": "2021",
"format": "dd/MM/yyyy||yyyy",
"time_zone": "+08:00"
}
}
}
}
//mysql:where createAt >= "2020-10-13T00:00:00Z" and createAt < "2021-01-01T00:00:00.000Z"
欸~如果看官有这种感觉,那很有天份呢~
其实Bool query就是最少一个的布林子句所够成
也就是说每个子句结果最後吐出都必须爲true or false
然而这个常出现的母集合其实只有四种子句
也就是我们上篇所提到的
POST _bulk
{"index":{"_index":"it_help","_type":"_doc","_id":"1"}}
{ "id" : 2,"content":"我爱台湾,国庆快乐" }
{"index":{"_index":"it_help","_type":"_doc","_id":"2"}}
{ "id" : 2,"content":"我爱台湾,国庆快乐" }
{"index":{"_index":"it_help","_type":"_doc","_id":"3"}}
{ "id" : 3,"content":"爱台湾,国庆快乐" }
{"index":{"_index":"it_help","_type":"_doc","_id":"4"}}
{ "id" : 4,"content":"国庆快乐,全国爱台湾" }
其中呢username=Field,jacky就是我们要找的值啦
参考文档
下面列出比较常用的参数呢爲荣
第29篇终於结束了
来回去加班罗~
<<: [Day 30] LeetCode - 125 Valid Palindrome
我们必须记忆一个主体的状态,以便系统後续进行判断、操作或其他使用,为此我们也在 Day 03 厘清「...
每天赛跑 铁人赛要迈入下半场了,回顾前半场...,每天回家吃完饭剩下 3-4 小时可以来写稿 偏偏假...
今天继续介绍如何在云端服务器上持续开启bot 但在进入replit之前需要在GitHub专案放进两个...
前言 有了前 2 篇从「台湾证券交易所」取得 CSV 档後,接着要把资料存入 DB,在存入前,需要先...
铁人赛的最後一天 以三个前端比较常见的情境练习需求来总结第五部分 今天的内容 一、注册表单 二、产品...