Pass percentile aggregation bucket values as params to a function_score/script_score filter

Hey, am looking for a way to pass values from a percentile aggregation to a function_score filter as a param in the script_score field, is this possible?

Something like this:

aggs: {
		query_percentiles: {
			percentiles: {
				keyed: false,
				script: {
					lang: "painless",
					source:
						"doc['field'].value"
				},
			},
		},
		aggs: {
			filter: {
				function_score: {
					query: {
						match_all: {}
					},
					functions: [
						{
							script_score: {
								script: {
									params: {
										percentiles: bucket_percentiles?
									},
									source: `bucket_percentiles[i].value>doc[field].value`
								}
							}
						}
					],

				}
			}
		}
	}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.