From 61bb9d0ff9dfdb101cb9653e837c6d610503441c Mon Sep 17 00:00:00 2001 From: kimchy Date: Tue, 10 Aug 2010 16:14:15 +0300 Subject: [PATCH] Mappers: also use `name` as a smart lookup for field/property on top of indexName and fullName, closes #309. --- .idea/dictionaries/kimchy.xml | 1 + .../index/mapper/DocumentFieldMappers.java | 9 +++++++-- .../elasticsearch/index/mapper/MapperService.java | 13 +++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.idea/dictionaries/kimchy.xml b/.idea/dictionaries/kimchy.xml index a4f1c2a4f7d..56397e4a249 100644 --- a/.idea/dictionaries/kimchy.xml +++ b/.idea/dictionaries/kimchy.xml @@ -26,6 +26,7 @@ cloudservers commitable committable + concat conf configurator coord diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java index b8eaaab8673..f1f2845758a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/DocumentFieldMappers.java @@ -112,14 +112,19 @@ public class DocumentFieldMappers implements Iterable { } /** - * Tries to find first based on {@link #fullName(String)}, then by {@link #indexName(String)}. + * Tries to find first based on {@link #fullName(String)}, then by {@link #indexName(String)}, and last + * by {@link #name(String)}. */ public FieldMappers smartName(String name) { FieldMappers fieldMappers = fullName(name); if (fieldMappers != null) { return fieldMappers; } - return indexName(name); + fieldMappers = indexName(name); + if (fieldMappers != null) { + return fieldMappers; + } + return name(name); } public FieldMapper smartNameFieldMapper(String name) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/MapperService.java index cb00c121a3a..feecabd668f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -259,7 +259,11 @@ public class MapperService extends AbstractIndexComponent implements IterableIt also (without the optional type prefix) try and find the {@link FieldMappers} for the specific * name. It will first try to find it based on the full name (with the dots if its a compound name). If - * it is not found, will try and find it based on the indexName (which can be controlled in the mapping). + * it is not found, will try and find it based on the indexName (which can be controlled in the mapping), + * and last, will try it based no the name itself. * *

If nothing is found, returns null. */ @@ -294,6 +299,10 @@ public class MapperService extends AbstractIndexComponent implements Iterable