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.

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

报告相同问题?

悬赏问题

  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备