小编Ser*_*erj的帖子

match_query里面的脚本?[elasticsearch]

我有一个非常复杂的聚合,它的复杂性是由缺少has_parent聚合引起的.因为它是使用groovy实现的.我唯一的问题是过滤聚合中计算的文档.

聚合看起来像这样:https://gist.github.com/serj-p/c4fcc9810b3b627de294 这个聚合的目的是建立顶尖的大学联系人毕业.联系人doc具有子文档,这是facebook个人资料.最后一个有代表大学的嵌套字段,这就是我访问_source字段的原因.

正如您可能看到的,我在开始时执行过滤:

                      {
                        "match_phrase_prefix": {
                          "organizations.name": "stan"
                        }
                      }
Run Code Online (Sandbox Code Playgroud)

排除没有相关文档的联系人."organizations.name"被分析为

           {
                "filter": [
                    "lowercase",
                    "standard",
                    "trim",
                    "asciifolding",
                ],
                "type": "custom",
                "tokenizer": "standard"
            }
Run Code Online (Sandbox Code Playgroud)

正在以相同的方式分析正在过滤此字段的文本.我发现很难对脚本中的字段值和过滤文本进行相同的处理,这应该过滤特定的嵌套文档.这就是为什么我正在寻找从脚本访问ES API的可能性.

提前感谢任何建议

elasticsearch elasticsearch-aggregation

7
推荐指数
0
解决办法
168
查看次数

加入Elasticsearch中的reverse_nested聚合

请帮助我找到一种机制来聚合以下域或证明它在当前API中不存在.

    curl -XDELETE 127.0.0.1:9200/test_index

    curl -XPUT 127.0.0.1:9200/test_index -d '{
        "mappings": {
            "contact": {
                "properties": {
                    "facebook_profile": {
                        "type": "nested",
                        "properties": {
                            "education": {
                                "type": "string"
                            },
                            "year": {
                                "type": "integer"
                            }
                        }
                    },
                    "google_profile": {
                        "type": "nested",
                        "properties": {
                            "education": {
                                "type": "string"
                            },
                            "year": {
                                "type": "integer"
                            }
                        }
                    }
                }
            }
        }
    }'

    curl -XPUT 127.0.0.1:9200/test_index/contact/contact1 -d '{
        "google_profile": {
            "education": "stanford", "year": 1990
        }
    }'

    curl -XPUT 127.0.0.1:9200/test_index/contact/contact2 -d '
    {
        "facebook_profile": {
            "education": "stanford", "year": 1990 …
Run Code Online (Sandbox Code Playgroud)

elasticsearch

5
推荐指数
1
解决办法
131
查看次数