Skip to content

feat: support script sort#22

Open
cobbinma wants to merge 2 commits into
mottaquikarim:masterfrom
cobbinma:feat/support-script-sort
Open

feat: support script sort#22
cobbinma wants to merge 2 commits into
mottaquikarim:masterfrom
cobbinma:feat/support-script-sort

Conversation

@cobbinma
Copy link
Copy Markdown
Contributor

@cobbinma cobbinma commented Mar 11, 2025

Hi

I have a query where I need to use a painless script sort but the current type of map[string]string isn't compatible with using complex sorts.

The issue is the json marshal will escape the sort string before marshalling it. Moving to map[string]interface will avoid escaping and enable us to use more complex types. The example below will work as intended:

	scriptSort := map[string]interface{}{
		"_script": map[string]interface{}{
			"type": "string",
			"script": map[string]interface{}{
				"source": "String name = doc['name'].value; return name.startsWith('name.prefix.') ? name.substring(12) : name;",
				"lang":   "painless",
			},
			"order": "asc",
		},
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant