Skip to content

Commit b11e4d2

Browse files
committed
👌 IMPROVE: Minor improvements for the addRuntimeMapping() method and docs
1 parent d0af284 commit b11e4d2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

‎docs/Searching/Search.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,22 @@ searchBuilder.addRuntimeMapping( "hasPricing", {
217217
} );
218218
```
219219

220-
This will result in an `"hasPricing"` field in the `fields` property on the `Document` object:
220+
Using `.addField()` ensures the field is returned with the document upon query completion:
221+
222+
```js
223+
searchBuilder.addRuntimeMapping( "hasPricing", ... ).addField( "hasPricing" );
224+
```
225+
226+
We can then retrieve the result field via the `getFields()` method:
221227

222228
```js
223229
var documentsWithPricing = searchBuilder.execute()
224230
.getHits()
225231
.filter( (document) => document.getFields()["hasPricing"] );
226232
```
227233

234+
or inlined with the document mento using `hit.getDocument( includeFields = true )`.
235+
228236
### Advanced Query DSL
229237

230238
The SearchBuilder also allows full use of the [Elasticsearch query language](https://www.elastic.co/guide/en/elasticsearch/reference/current/_introducing_the_query_language.html), allowing full configuration of your search queries. There are several methods to provide the raw query language to the Search Builder. One is during instantiation.

‎models/SearchBuilder.cfc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,7 @@ component accessors="true" {
13731373
return this;
13741374
}
13751375

1376+
13761377
/**
13771378
* Append a search-time (runtime) mapping to the search.
13781379
*
@@ -1382,8 +1383,7 @@ component accessors="true" {
13821383
*/
13831384
public SearchBuilder function addRuntimeMapping(
13841385
required string name,
1385-
struct script,
1386-
any source = true
1386+
struct script
13871387
){
13881388
if ( isNull( variables.runtimeMappings ) ) {
13891389
variables.runtimeMappings = {};

0 commit comments

Comments
 (0)