Skip to content

Commit 83bf2c7

Browse files
committed
Add mappings handling for wildcard pattern
1 parent 6f8cac7 commit 83bf2c7

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

models/io/HyperClient.cfc

+18-13
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ component accessors="true" threadSafe singleton {
266266
}
267267
}
268268

269-
269+
270270

271271
/**
272272
* Returns the mappings for an index
@@ -278,25 +278,30 @@ component accessors="true" threadSafe singleton {
278278
var path = arguments.indexName & "/_mapping";
279279
if( !isNull( arguments.field ) ){
280280
path &= "/field/" & arguments.field;
281+
} else if( findNoCase( "*", arguments.indexName ) ){
282+
// if a wild card is present we are only interested in the fields
283+
arguments.field = "*";
284+
path &= "/field/" & arguments.field;
281285
}
282286
var response = variables.nodePool.newRequest( path, "GET" ).send();
283287

284288
if ( response.getStatusCode() != 200 ) {
285289
onResponseFailure( response );
286290
} else {
291+
var mappings = response.json();
287292
return isNull( arguments.field )
288-
? response.json()[ indexName ].mappings
289-
: response.json().reduce( ( acc, indexKey, value ) => {
290-
value.mappings.keyArray().each( ( mappingKey ) => {
291-
if( !acc.keyExists( mappingKey ) ){
292-
acc[ mappingKey ] = value.mappings[ mappingKey ];
293-
acc[ mappingKey ]["indices"] = [ indexKey ];
294-
} else {
295-
acc[ mappingKey ]["indices"].append( indexKey );
296-
}
297-
} );
298-
return acc;
299-
}, {} );
293+
? mappings[ indexName ].mappings
294+
: mappings.reduce( ( acc, indexKey, value ) => {
295+
value.mappings.keyArray().each( ( mappingKey ) => {
296+
if( !acc.keyExists( mappingKey ) ){
297+
acc[ mappingKey ] = value.mappings[ mappingKey ];
298+
acc[ mappingKey ]["indices"] = [ indexKey ];
299+
} else {
300+
acc[ mappingKey ]["indices"].append( indexKey );
301+
}
302+
} );
303+
return acc;
304+
}, {} );
300305
}
301306
}
302307

0 commit comments

Comments
 (0)