match_query inside script? [elasticsearch]

百般思念 提交于 2019-12-08 18:03:28

问题


I have a quite complex aggregation, its complexity is caused by absence of has_parent aggregation. Since so it's implemented using groovy. The only problem I have is to filter docs being counted in the aggregation.

Aggregation looks like this: https://gist.github.com/serj-p/c4fcc9810b3b627de294 the aim of this aggregation is to build the top of universities contacts are graduated from. A contact doc has child docs, which are facebook profiles. Last ones have nested fields representing universities, that's why I access _source field.

As you probably can see, I perform filtering in the beginning :

                      {
                        "match_phrase_prefix": {
                          "organizations.name": "stan"
                        }
                      }

to exclude contacts not having relevant docs. "organizations.name" is analyzed as

           {
                "filter": [
                    "lowercase",
                    "standard",
                    "trim",
                    "asciifolding",
                ],
                "type": "custom",
                "tokenizer": "standard"
            }

the text being appleid to filter this field is being analyzed in the same way. I found it very difficult to do the same processing of a field value and a filtering text inside of the script which should filter particular nested docs. That's why I am looking for some possibility to access ES API from the script to do so.

Thanks in advance for any advice

来源:https://stackoverflow.com/questions/35061945/match-query-inside-script-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!