mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 06:25:07 +00:00
Merge pull request #16508 from s1monw/issues/16378
Add field names to several mapping errors
This commit is contained in:
commit
5cbc7bb93e
@ -145,8 +145,8 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc
|
|||||||
|
|
||||||
public static class TypeParser implements Mapper.TypeParser {
|
public static class TypeParser implements Mapper.TypeParser {
|
||||||
@Override
|
@Override
|
||||||
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
public Mapper.Builder parse(String fieldName, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||||
StringFieldMapper.Builder builder = stringField(name);
|
StringFieldMapper.Builder builder = stringField(fieldName);
|
||||||
// hack for the fact that string can't just accept true/false for
|
// hack for the fact that string can't just accept true/false for
|
||||||
// the index property and still accepts no/not_analyzed/analyzed
|
// the index property and still accepts no/not_analyzed/analyzed
|
||||||
final Object index = node.remove("index");
|
final Object index = node.remove("index");
|
||||||
@ -165,10 +165,10 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc
|
|||||||
node.put("index", false);
|
node.put("index", false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Can't parse [index] value [" + index + "], expected [true], [false], [no], [not_analyzed] or [analyzed]");
|
throw new IllegalArgumentException("Can't parse [index] value [" + index + "] for field [" + fieldName + "], expected [true], [false], [no], [not_analyzed] or [analyzed]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parseTextField(builder, name, node, parserContext);
|
parseTextField(builder, fieldName, node, parserContext);
|
||||||
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
|
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
|
||||||
Map.Entry<String, Object> entry = iterator.next();
|
Map.Entry<String, Object> entry = iterator.next();
|
||||||
String propName = Strings.toUnderscoreCase(entry.getKey());
|
String propName = Strings.toUnderscoreCase(entry.getKey());
|
||||||
@ -182,7 +182,7 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc
|
|||||||
} else if (propName.equals("search_quote_analyzer")) {
|
} else if (propName.equals("search_quote_analyzer")) {
|
||||||
NamedAnalyzer analyzer = parserContext.analysisService().analyzer(propNode.toString());
|
NamedAnalyzer analyzer = parserContext.analysisService().analyzer(propNode.toString());
|
||||||
if (analyzer == null) {
|
if (analyzer == null) {
|
||||||
throw new MapperParsingException("Analyzer [" + propNode.toString() + "] not found for field [" + name + "]");
|
throw new MapperParsingException("Analyzer [" + propNode.toString() + "] not found for field [" + fieldName + "]");
|
||||||
}
|
}
|
||||||
builder.searchQuotedAnalyzer(analyzer);
|
builder.searchQuotedAnalyzer(analyzer);
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
@ -207,7 +207,7 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc
|
|||||||
} else if (propName.equals("ignore_above")) {
|
} else if (propName.equals("ignore_above")) {
|
||||||
builder.ignoreAbove(XContentMapValues.nodeIntegerValue(propNode, -1));
|
builder.ignoreAbove(XContentMapValues.nodeIntegerValue(propNode, -1));
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
} else if (parseMultiField(builder, name, parserContext, propName, propNode)) {
|
} else if (parseMultiField(builder, fieldName, parserContext, propName, propNode)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ public class TypeParsers {
|
|||||||
case "false":
|
case "false":
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Can't parse [index] value [" + index + "], expected [true] or [false]");
|
throw new IllegalArgumentException("Can't parse [index] value [" + index + "] for field [" + fieldName + "], expected [true] or [false]");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final String normalizedIndex = Strings.toUnderscoreCase(index);
|
final String normalizedIndex = Strings.toUnderscoreCase(index);
|
||||||
@ -349,7 +349,7 @@ public class TypeParsers {
|
|||||||
case "no":
|
case "no":
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Can't parse [index] value [" + index + "], expected [true], [false], [no], [not_analyzed] or [analyzed]");
|
throw new IllegalArgumentException("Can't parse [index] value [" + index + "] for field [" + fieldName + "], expected [true], [false], [no], [not_analyzed] or [analyzed]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -388,7 +388,7 @@ public class TypeParsers {
|
|||||||
}
|
}
|
||||||
SimilarityProvider similarityProvider = parserContext.getSimilarity(value);
|
SimilarityProvider similarityProvider = parserContext.getSimilarity(value);
|
||||||
if (similarityProvider == null) {
|
if (similarityProvider == null) {
|
||||||
throw new MapperParsingException("Unknown Similarity type [" + value + "] for [" + name + "]");
|
throw new MapperParsingException("Unknown Similarity type [" + value + "] for field [" + name + "]");
|
||||||
}
|
}
|
||||||
return similarityProvider;
|
return similarityProvider;
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ public class SimilarityTests extends ESSingleNodeTestCase {
|
|||||||
indexService.mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
indexService.mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
fail("Expected MappingParsingException");
|
fail("Expected MappingParsingException");
|
||||||
} catch (MapperParsingException e) {
|
} catch (MapperParsingException e) {
|
||||||
assertThat(e.getMessage(), equalTo("Unknown Similarity type [unknown_similarity] for [field1]"));
|
assertThat(e.getMessage(), equalTo("Unknown Similarity type [unknown_similarity] for field [field1]"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ public class SimilarityTests extends ESSingleNodeTestCase {
|
|||||||
parser.parse("type", new CompressedXContent(mapping));
|
parser.parse("type", new CompressedXContent(mapping));
|
||||||
fail("Expected MappingParsingException");
|
fail("Expected MappingParsingException");
|
||||||
} catch (MapperParsingException e) {
|
} catch (MapperParsingException e) {
|
||||||
assertThat(e.getMessage(), equalTo("Unknown Similarity type [default] for [field1]"));
|
assertThat(e.getMessage(), equalTo("Unknown Similarity type [default] for field [field1]"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user