本文整理汇总了Java中org.elasticsearch.index.mapper.Mapper.TypeParser方法的典型用法代码示例。如果您正苦于以下问题:Java Mapper.TypeParser方法的具体用法?Java Mapper.TypeParser怎么用?Java Mapper.TypeParser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.index.mapper.Mapper
的用法示例。
在下文中一共展示了Mapper.TypeParser方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newTestIndicesModule
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
/** Creates an IndicesModule for testing with the given mappers and metadata mappers. */
public static IndicesModule newTestIndicesModule(Map<String, Mapper.TypeParser> extraMappers,
Map<String, MetadataFieldMapper.TypeParser> extraMetadataMappers) {
return new IndicesModule(Collections.singletonList(
new MapperPlugin() {
@Override
public Map<String, Mapper.TypeParser> getMappers() {
return extraMappers;
}
@Override
public Map<String, MetadataFieldMapper.TypeParser> getMetadataMappers() {
return extraMetadataMappers;
}
}
));
}
示例2: testDuplicateOtherPluginMapper
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
public void testDuplicateOtherPluginMapper() {
MapperPlugin plugin = new MapperPlugin() {
@Override
public Map<String, Mapper.TypeParser> getMappers() {
return Collections.singletonMap("foo", new FakeMapperParser());
}
};
List<MapperPlugin> plugins = Arrays.asList(plugin, plugin);
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> new IndicesModule(plugins));
assertThat(e.getMessage(), Matchers.containsString("already registered"));
}
示例3: getMappers
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
@Override
public Map<String, Mapper.TypeParser> getMappers() {
Map<String, Mapper.TypeParser> mappers = new HashMap<>();
mappers.put(EXTERNAL, new ExternalMapper.TypeParser(EXTERNAL, "foo"));
mappers.put(EXTERNAL_BIS, new ExternalMapper.TypeParser(EXTERNAL_BIS, "bar"));
mappers.put(EXTERNAL_UPPER, new ExternalMapper.TypeParser(EXTERNAL_UPPER, "FOO BAR"));
mappers.put(FakeStringFieldMapper.CONTENT_TYPE, new FakeStringFieldMapper.TypeParser());
return Collections.unmodifiableMap(mappers);
}
示例4: registerMapper
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
/**
* Register a mapper for the given type.
*/
public synchronized void registerMapper(String type, Mapper.TypeParser parser) {
if (mapperParsers.containsKey(type)) {
throw new IllegalArgumentException("A mapper is already registered for type [" + type + "]");
}
mapperParsers.put(type, parser);
}
示例5: findTemplateBuilder
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
public Mapper.Builder findTemplateBuilder(ParseContext context, String name, String dynamicType, String matchType) {
DynamicTemplate dynamicTemplate = findTemplate(context.path(), name, matchType);
if (dynamicTemplate == null) {
return null;
}
Mapper.TypeParser.ParserContext parserContext = context.docMapperParser().parserContext(name);
String mappingType = dynamicTemplate.mappingType(dynamicType);
Mapper.TypeParser typeParser = parserContext.typeParser(mappingType);
if (typeParser == null) {
throw new MapperParsingException("failed to find type parsed [" + mappingType + "] for [" + name + "]");
}
return typeParser.parse(name, dynamicTemplate.mappingForName(name, dynamicType), parserContext);
}
示例6: getMappers
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
@Override
public Map<String, Mapper.TypeParser> getMappers() {
return Collections.singletonMap(PercolatorFieldMapper.CONTENT_TYPE, new PercolatorFieldMapper.TypeParser());
}
示例7: MapperRegistry
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
public MapperRegistry(Map<String, Mapper.TypeParser> mapperParsers,
Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers) {
this.mapperParsers = Collections.unmodifiableMap(new LinkedHashMap<>(mapperParsers));
this.metadataMapperParsers = Collections.unmodifiableMap(new LinkedHashMap<>(metadataMapperParsers));
}
示例8: getMappers
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
@Override
public Map<String, Mapper.TypeParser> getMappers() {
return Collections.singletonMap("fake-mapper", new KeywordFieldMapper.TypeParser());
}
示例9: getMappers
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
@Override
public Map<String, Mapper.TypeParser> getMappers() {
return Collections.singletonMap("fake-mapper", new FakeMapperParser());
}
示例10: getMappers
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
@Override
public Map<String, Mapper.TypeParser> getMappers() {
return Collections.singletonMap(Murmur3FieldMapper.CONTENT_TYPE, new Murmur3FieldMapper.TypeParser());
}
示例11: parseProperties
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
protected static void parseProperties(ObjectMapper.Builder objBuilder, Map<String, Object> propsNode, ParserContext parserContext) {
Iterator<Map.Entry<String, Object>> iterator = propsNode.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, Object> entry = iterator.next();
String fieldName = entry.getKey();
if (fieldName.contains(".")) {
throw new MapperParsingException("Field name [" + fieldName + "] cannot contain '.'");
}
// Should accept empty arrays, as a work around for when the
// user can't provide an empty Map. (PHP for example)
boolean isEmptyList = entry.getValue() instanceof List && ((List<?>) entry.getValue()).isEmpty();
if (entry.getValue() instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> propNode = (Map<String, Object>) entry.getValue();
/* mark delete field when reindex */
Object deleteNode = propNode.get("delete");
if (deleteNode != null && deleteNode.toString().equals("true")) {
/* TODO GaoPan: mark delete field when reindex */
iterator.remove();
} else {
String type;
Object typeNode = propNode.get("type");
if (typeNode != null) {
type = typeNode.toString();
} else {
// lets see if we can derive this...
if (propNode.get("properties") != null) {
type = ObjectMapper.CONTENT_TYPE;
} else if (propNode.size() == 1 && propNode.get("enabled") != null) {
// if there is a single property with the enabled
// flag on it, make it an object
// (usually, setting enabled to false to not index
// any type, including core values, which
type = ObjectMapper.CONTENT_TYPE;
} else {
throw new MapperParsingException("No type specified for field [" + fieldName + "]");
}
}
Mapper.TypeParser typeParser = parserContext.typeParser(type);
if (typeParser == null) {
throw new MapperParsingException("No handler for type [" + type + "] declared on field [" + fieldName + "]");
}
objBuilder.add(typeParser.parse(fieldName, propNode, parserContext));
propNode.remove("type");
DocumentMapperParser.checkNoRemainingFields(fieldName, propNode, parserContext.indexVersionCreated());
iterator.remove();
}
} else if (isEmptyList) {
iterator.remove();
} else {
throw new MapperParsingException("Expected map for property [fields] on field [" + fieldName + "] but got a "
+ fieldName.getClass());
}
}
DocumentMapperParser.checkNoRemainingFields(propsNode, parserContext.indexVersionCreated(),
"DocType mapping definition has unsupported parameters: ");
}
示例12: parseMultiField
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
public static boolean parseMultiField(FieldMapper.Builder builder, String name, Mapper.TypeParser.ParserContext parserContext, String propName, Object propNode) {
parserContext = parserContext.createMultiFieldContext(parserContext);
if (propName.equals("path") && parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) {
builder.multiFieldPathType(parsePathType(name, propNode.toString()));
return true;
} else if (propName.equals("fields")) {
final Map<String, Object> multiFieldsPropNodes;
if (propNode instanceof List && ((List<?>) propNode).isEmpty()) {
multiFieldsPropNodes = Collections.emptyMap();
} else if (propNode instanceof Map) {
multiFieldsPropNodes = (Map<String, Object>) propNode;
} else {
throw new MapperParsingException("expected map for property [fields] on field [" + propNode + "] or " +
"[" + propName + "] but got a " + propNode.getClass());
}
for (Map.Entry<String, Object> multiFieldEntry : multiFieldsPropNodes.entrySet()) {
String multiFieldName = multiFieldEntry.getKey();
if (multiFieldName.contains(".")) {
throw new MapperParsingException("Field name [" + multiFieldName + "] which is a multi field of [" + name + "] cannot contain '.'");
}
if (!(multiFieldEntry.getValue() instanceof Map)) {
throw new MapperParsingException("illegal field [" + multiFieldName + "], only fields can be specified inside fields");
}
@SuppressWarnings("unchecked")
Map<String, Object> multiFieldNodes = (Map<String, Object>) multiFieldEntry.getValue();
String type;
Object typeNode = multiFieldNodes.get("type");
if (typeNode != null) {
type = typeNode.toString();
} else {
throw new MapperParsingException("no type specified for property [" + multiFieldName + "]");
}
if (type.equals(ObjectMapper.CONTENT_TYPE) || type.equals(ObjectMapper.NESTED_CONTENT_TYPE)) {
throw new MapperParsingException("Type [" + type + "] cannot be used in multi field");
}
Mapper.TypeParser typeParser = parserContext.typeParser(type);
if (typeParser == null) {
throw new MapperParsingException("no handler for type [" + type + "] declared on field [" + multiFieldName + "]");
}
builder.addMultiField(typeParser.parse(multiFieldName, multiFieldNodes, parserContext));
multiFieldNodes.remove("type");
DocumentMapperParser.checkNoRemainingFields(propName, multiFieldNodes, parserContext.indexVersionCreated());
}
return true;
}
return false;
}
示例13: getMapperParsers
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
/**
* Return a map of the mappers that have been registered. The
* returned map uses the type of the field as a key.
*/
public Map<String, Mapper.TypeParser> getMapperParsers() {
return mapperParsers;
}
示例14: getMappers
import org.elasticsearch.index.mapper.Mapper; //导入方法依赖的package包/类
/**
* Returns additional mapper implementations added by this plugin.
*
* The key of the returned {@link Map} is the unique name for the mapper which will be used
* as the mapping {@code type}, and the value is a {@link Mapper.TypeParser} to parse the
* mapper settings into a {@link Mapper}.
*/
default Map<String, Mapper.TypeParser> getMappers() {
return Collections.emptyMap();
}