Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add runtime mappings support via addRuntimeMapping() #132

Conversation

michaelborn
Copy link
Contributor

@michaelborn michaelborn commented Mar 28, 2024

Implement Elasticsearch runtime mappings via a new addRuntimeMapping() method in the search builder:

searchBuilder.addRuntimeMapping( "hasPricing", {
	"type" : "boolean",
	"script": {
		"source": "doc.containsKey( 'price' )"
	}
} );

Using .addField() ensures the field is returned with the document upon query completion:

searchBuilder.addRuntimeMapping( "hasPricing", ... )
.addField( "hasPricing" );

We can retrieve the result field via the getFields() method:

var documentsWithPricing = searchBuilder.execute()
	.getHits()
	.filter( (document) => document.getFields()["hasPricing"] );

or inlined with the document mento using hit.getDocument( includeFields = true ).

@michaelborn
Copy link
Contributor Author

Marking this PR as WIP, because I didn't finish testing the actual field retrieval.

@michaelborn michaelborn changed the title WIP: Add runtime mappings support via addRuntimeMapping() Add runtime mappings support via addRuntimeMapping() Apr 18, 2024
@michaelborn michaelborn requested a review from jclausen April 18, 2024 14:33
@jclausen jclausen merged commit d55d8cc into coldbox-modules:development Apr 18, 2024
17 of 19 checks passed
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.

2 participants