Skip to content

Commit cc290b1

Browse files
committed
Ids with # in them will cause search failures, also, fail when # is used in a type name, closes elastic#728.
1 parent cdfcea1 commit cc290b1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/MapperService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ public void add(String type, String mappingSource) {
148148
private void add(DocumentMapper mapper) {
149149
synchronized (mutex) {
150150
if (mapper.type().charAt(0) == '_') {
151-
throw new InvalidTypeNameException("Document mapping type name can't start with '_'");
151+
throw new InvalidTypeNameException("mapping type name [" + mapper.type() + "] can't start with '_'");
152+
}
153+
if (mapper.type().contains("#")) {
154+
throw new InvalidTypeNameException("mapping type name [" + mapper.type() + "] should not include '#' in it");
152155
}
153156
remove(mapper.type()); // first remove it (in case its an update, we need to remove the aggregated mappers)
154157
mappers = newMapBuilder(mappers).put(mapper.type(), mapper).immutableMap();

modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/Uid.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public String id() {
6666
}
6767

6868
public static Uid createUid(String uid) {
69-
int delimiterIndex = uid.lastIndexOf(DELIMITER);
69+
int delimiterIndex = uid.indexOf(DELIMITER); // type is not allowed to have # in it..., ids can
7070
return new Uid(uid.substring(0, delimiterIndex), uid.substring(delimiterIndex + 1));
7171
}
7272

0 commit comments

Comments
 (0)