问题描述
我目前有以下类型:
aggs:{
group_by_myfield:{
:{
field:myfield
}
}
}
然而,myfield的值是alpha 1.0,alpha 2.0,beta 1.0。现在我只想聚合超过alpha,beta的值。我怎么做?我试过:
aggs:{
p>
group_by_myfield:{
terms:{
field:myfield
script:_value.split()[0]
}
}
}
但我想没有拆分功能。欢迎任何建议!
我发现了类似的问题,这是没有答案的。
编辑:
设法使用上面的链接完成。以下查询完成工作。
GET _search
{
size:0,
aggs :{
group_by_myfield:{
terms:{
field:myfield,
script:_value.replaceAll('\\\ \\s +。*','')
}
}
}
}
设法使用我粘贴在我的问题中的链接完成:
$ _
$ bsize:0,
aggs:{
group_by_myfield:{
terms:{
字段:myfield,
脚本:_value.replaceAll('\\\\\s +。*','')
}
}
}
}
I currently have something like:
"aggs": { "group_by_myfield": { "terms": { "field": "myfield" } } }
However the value for myfield is "alpha 1.0", "alpha 2.0", "beta 1.0". Now I want to only aggregate over the values "alpha", "beta". How do I do that? I tried:
"aggs": { "group_by_myfield": { "terms": { "field": "myfield" "script": "_value.split()[0]" } } }
But I guess there is no split functionality. Any suggestions are welcome!
I found a similar question here which is unanswered as well.
EDIT:managed to get it done using the link above. following query does the job.
GET _search{ "size": 0, "aggs": { "group_by_myfield": { "terms": { "field": "myfield", "script": "_value.replaceAll('\\\\s+.*','')" } } }}
managed to get it done using the link I pasted in my question:
GET _search{ "size": 0, "aggs": { "group_by_myfield": { "terms": { "field": "myfield", "script": "_value.replaceAll('\\\\s+.*','')" } } }}
这篇关于弹性搜索聚合使用脚本来转换正在聚合的字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!