[英]how to filter with script in elasticsearch
I need to search for something like this我需要搜索这样的东西
POST dev_profiles/profiles/_search
{
"query": {
"bool": {
"filter": [
{
"query_string": {
"query": "user:asd"
},
"script_fields": {
"message_age": {
"script": {
"source": "return doc.createdAt.value.getHour() == params.h",
"params": {
"h": 9
}
}
}
}
}
]
}
}
}
but can't build a query in the right way.但无法以正确的方式构建查询。 Can somebody help?
有人可以帮忙吗?
In that case, it gives error [query_string] malformed query, expected [END_OBJECT] but found [FIELD_NAME] version of elasticsearch 6.8在这种情况下,它会给出错误 [query_string] 格式错误的查询,应为 [END_OBJECT] 但找到 elasticsearch 6.8 的 [FIELD_NAME] 版本
The query you're looking for is like this:您要查找的查询是这样的:
{
"query": {
"bool": {
"filter": [
{
"match": {
"user": "asd"
}
}
{
"script": {
"script": {
"source": "return doc.createdAt.value.getHour() == params.h",
"params": {
"h": 9
}
}
}
}
]
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.