duandaishi9268 2016-06-06 08:38
浏览 47
已采纳

过滤后嵌套字段的聚合

I'm triying to get all the logs around a expecific geopoint, and group them by a subfield (context.id) but I'm having problems. I tried the nested aggregation, etc.. but I'm having no luck. I'm using the PHP library so I wrote the query as a php array. All is working until addign the aggregation query.

The exception throw is :

illegal_state_exception: Field data loading is forbidden on [context.id]


$params = [
        'index' => 'logstash-*',
        'type'  => 'INFO',
        'body'  => [
            'query' => [
                'bool' => [
                    "must"   => [
                        ["term" => ["tags" => "producer"]],
                        ["term" => ["tags" => "statistics"]],
                        ["term" => ["message" => "view"]],
                    ],
                    "filter" => [
                        "geo_distance" => [
                            "distance"       => "10km",
                            "distance_type"  => "plane",
                            "geoip.location" => [
                                "lat" => 40.4326058,
                                "lon" => -3.6996032
                            ]
                        ]
                    ]
                ]
            ],
            "aggs"  => [
                "context" => [
                    "nested" => [
                        "path" => "context"
                    ],
                    "aggs"   => [
                        "group_by_id" => [
                            "terms" => ["field" => "context.id"]
                        ]
                    ]
                ]
            ],
        ]
    ];

Can someone point me to the right query?

  • 写回答

1条回答 默认 最新

  • doubei8168 2016-06-13 15:20
    关注

    Finally, the problem here was the field. It was a indexed field I need to use the "context.id.raw" field instead.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探