elasticsearch - Elasticsearch bool must query
问题描述
I am trying to write a Elasticsearch bool query. I am having an issue querying an field (DATE) using bool must query. Elastic search data look like so:
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 15,
"successful": 15,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 11.519888,
"hits": [
{
"_index": "test-2019.06.27",
"_type": "test",
"_id": "pa6gmGsByDlvLvAyiRF-",
"_score": 11.519888,
"_source": {
"DATE": "01/06/19"
}
}
]
}
}
Elasticsearch query like that:
{
"query":
{
"bool" : {
"must" : [
{
"match" : {
"DATE" : {
"query" : "01/06/19",
"operator" : "AND",
"prefix_length" : 0,
"max_expansions" : 50,
"fuzzy_transpositions" : true,
"lenient" : false,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : true,
"boost" : 1.0
}
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
}
The query is not working. Any idea please?
解决方案
试试下面的代码,
{
"query": {
"range" : {
"DATE" : {
"gte" : "now-1d/d",
"lt" : "now/d"
}
}
}
}
推荐阅读
- r - R / RStudio 非常缓慢
- sql - SQL中的正则表达式提取函数实现?
- java - Android Shared Preferences 防止在存储对象时覆盖
- python - for 循环中的范围为 1?
- python - 在 python 中使用 OAuth2 上传到谷歌照片
- python - 为什么这个 pygame 程序不起作用,所以当我将鼠标悬停在计算机屏幕上时它变成蓝色?
- python - 为什么二进制数的 str(num) 只返回特定数字作为字符串?
- wpf - 如何在 Windows 10 上为 WPF 应用程序的工具栏查找默认图标?
- c++ - c++11如何将十六进制字符串转换为unicode字符串
- pagespeed - Preconnect html vs header:哪个更快?