Ids with # in them will cause search failures, also, fail when # is used in a type name, closes #728.

This commit is contained in:
kimchy 2011-02-28 22:43:48 +02:00
parent 3bac33e69e
commit 906ec57f20
2 changed files with 5 additions and 2 deletions

View File

@ -148,7 +148,10 @@ public class MapperService extends AbstractIndexComponent implements Iterable<Do
private void add(DocumentMapper mapper) {
synchronized (mutex) {
if (mapper.type().charAt(0) == '_') {
throw new InvalidTypeNameException("Document mapping type name can't start with '_'");
throw new InvalidTypeNameException("mapping type name [" + mapper.type() + "] can't start with '_'");
}
if (mapper.type().contains("#")) {
throw new InvalidTypeNameException("mapping type name [" + mapper.type() + "] should not include '#' in it");
}
remove(mapper.type()); // first remove it (in case its an update, we need to remove the aggregated mappers)
mappers = newMapBuilder(mappers).put(mapper.type(), mapper).immutableMap();

View File

@ -66,7 +66,7 @@ public final class Uid {
}
public static Uid createUid(String uid) {
int delimiterIndex = uid.lastIndexOf(DELIMITER);
int delimiterIndex = uid.indexOf(DELIMITER); // type is not allowed to have # in it..., ids can
return new Uid(uid.substring(0, delimiterIndex), uid.substring(delimiterIndex + 1));
}