@@ -255,6 +255,17 @@ public FieldMappers smartNameFieldMappers(String smartName) {
255
255
return indexName (smartName );
256
256
}
257
257
258
+ /**
259
+ * Returns smart field mappers based on a smart name. A smart name is one that can optioannly be prefixed
260
+ * with a type (and then a '.'). If it is, then the {@link MapperService.SmartNameFieldMappers}
261
+ * will have the doc mapper set.
262
+ *
263
+ * <p>It also (without the optional type prefix) try and find the {@link FieldMappers} for the specific
264
+ * name. It will first try to find it based on the full name (with the dots if its a compound name). If
265
+ * it is not found, will try and find it based on the indexName (which can be controlled in the mapping).
266
+ *
267
+ * <p>If nothing is found, returns null.
268
+ */
258
269
public SmartNameFieldMappers smartName (String smartName ) {
259
270
int dotIndex = smartName .indexOf ('.' );
260
271
if (dotIndex != -1 ) {
@@ -336,7 +347,12 @@ private SmartIndexNameSearchAnalyzer(Analyzer defaultAnalyzer) {
336
347
return possibleDocMapper .mappers ().searchAnalyzer ().tokenStream (fieldName , reader );
337
348
}
338
349
}
339
- FieldMappers mappers = indexNameFieldMappers .get (fieldName );
350
+ FieldMappers mappers = fullNameFieldMappers .get (fieldName );
351
+ if (mappers != null && mappers .mapper () != null && mappers .mapper ().searchAnalyzer () != null ) {
352
+ return mappers .mapper ().searchAnalyzer ().tokenStream (fieldName , reader );
353
+ }
354
+
355
+ mappers = indexNameFieldMappers .get (fieldName );
340
356
if (mappers != null && mappers .mapper () != null && mappers .mapper ().searchAnalyzer () != null ) {
341
357
return mappers .mapper ().searchAnalyzer ().tokenStream (fieldName , reader );
342
358
}
@@ -352,7 +368,12 @@ private SmartIndexNameSearchAnalyzer(Analyzer defaultAnalyzer) {
352
368
return possibleDocMapper .mappers ().searchAnalyzer ().reusableTokenStream (fieldName , reader );
353
369
}
354
370
}
355
- FieldMappers mappers = indexNameFieldMappers .get (fieldName );
371
+ FieldMappers mappers = fullNameFieldMappers .get (fieldName );
372
+ if (mappers != null && mappers .mapper () != null && mappers .mapper ().searchAnalyzer () != null ) {
373
+ return mappers .mapper ().searchAnalyzer ().reusableTokenStream (fieldName , reader );
374
+ }
375
+
376
+ mappers = indexNameFieldMappers .get (fieldName );
356
377
if (mappers != null && mappers .mapper () != null && mappers .mapper ().searchAnalyzer () != null ) {
357
378
return mappers .mapper ().searchAnalyzer ().reusableTokenStream (fieldName , reader );
358
379
}
0 commit comments