Scripting - custom script to generate span query?

Our search use case uses Span Queries.

Due to the nature of our data and Span Queries the "query" definition has to be always dynamic as we have to analyse the search text, eg:

"quick brown fox" ->


{
	"query": {
		"span_near": {
			"clauses": [
				{
					"span_term": {
						"my_field": "quick"
					}
				},
				{
					"span_term": {
						"my_field": "brown"
					}
				},
				{
					"span_term": {
						"my_field": "fox"
					}
				}
			],
			"slop": 1,
			"in_order": false,
			"boost": 10
		}
		
	},
}

Currently we do analyse the query string (split into tokens, asci, lowercase, etc) on the client side, where we build also dynamically the "query".

Is it possible to move such logic to ElasticSearch by using Scripting, or other means?

Thanks!

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