本文整理汇总了Java中org.elasticsearch.index.mapper.core.StringFieldMapper类的典型用法代码示例。如果您正苦于以下问题:Java StringFieldMapper类的具体用法?Java StringFieldMapper怎么用?Java StringFieldMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringFieldMapper类属于org.elasticsearch.index.mapper.core包,在下文中一共展示了StringFieldMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: failIfFieldMappingNotFound
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
private MappedFieldType failIfFieldMappingNotFound(String name, MappedFieldType fieldMapping) {
if (fieldMapping != null || allowUnmappedFields) {
return fieldMapping;
} else if (mapUnmappedFieldAsString){
StringFieldMapper.Builder builder = MapperBuilders.stringField(name);
// it would be better to pass the real index settings, but they are not easily accessible from here...
Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, indexQueryParser.getIndexCreatedVersion()).build();
return builder.build(new Mapper.BuilderContext(settings, new ContentPath(1))).fieldType();
} else {
Version indexCreatedVersion = indexQueryParser.getIndexCreatedVersion();
if (fieldMapping == null && indexCreatedVersion.onOrAfter(Version.V_1_4_0_Beta1)) {
throw new QueryParsingException(this, "Strict field resolution and no field mapping can be found for the field with name ["
+ name + "]");
} else {
return fieldMapping;
}
}
}
示例2: updateFieldType
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
@Override
public FieldMapper updateFieldType(Map<String, MappedFieldType> fullNameToFieldType) {
BaseGeoPointFieldMapper updated = (BaseGeoPointFieldMapper) super.updateFieldType(fullNameToFieldType);
StringFieldMapper geoUpdated = geoHashMapper == null ? null : (StringFieldMapper) geoHashMapper.updateFieldType(fullNameToFieldType);
DoubleFieldMapper latUpdated = latMapper == null ? null : (DoubleFieldMapper) latMapper.updateFieldType(fullNameToFieldType);
DoubleFieldMapper lonUpdated = lonMapper == null ? null : (DoubleFieldMapper) lonMapper.updateFieldType(fullNameToFieldType);
if (updated == this
&& geoUpdated == geoHashMapper
&& latUpdated == latMapper
&& lonUpdated == lonMapper) {
return this;
}
if (updated == this) {
updated = (BaseGeoPointFieldMapper) updated.clone();
}
updated.geoHashMapper = geoUpdated;
updated.latMapper = latUpdated;
updated.lonMapper = lonUpdated;
return updated;
}
示例3: configureRootObjectBuilder
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
@Override
protected void configureRootObjectBuilder(RootObjectMapper.Builder builder) {
builder
.add(new DateFieldMapper.Builder("dateTime"))
.add(new FloatFieldMapper.Builder("temperature"))
.add(new FloatFieldMapper.Builder("windSpeed"))
.add(new FloatFieldMapper.Builder("stationPressure"))
.add(new StringFieldMapper.Builder("skyCondition"))
.add(new ObjectMapper.Builder("station")
.add(new StringFieldMapper.Builder("wban"))
.add(new StringFieldMapper.Builder("name"))
.add(new StringFieldMapper.Builder("state"))
.add(new StringFieldMapper.Builder("location"))
.add(new GeoPointFieldMapper.Builder("coordinates")
.enableLatLon(true)
.enableGeoHash(false))
.nested(ObjectMapper.Nested.newNested(true, false)));
}
示例4: registerBuiltInMappers
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
private static Map<String, Mapper.TypeParser> registerBuiltInMappers() {
Map<String, Mapper.TypeParser> mapperParsers = new LinkedHashMap<>();
mapperParsers.put(ByteFieldMapper.CONTENT_TYPE, new ByteFieldMapper.TypeParser());
mapperParsers.put(ShortFieldMapper.CONTENT_TYPE, new ShortFieldMapper.TypeParser());
mapperParsers.put(IntegerFieldMapper.CONTENT_TYPE, new IntegerFieldMapper.TypeParser());
mapperParsers.put(LongFieldMapper.CONTENT_TYPE, new LongFieldMapper.TypeParser());
mapperParsers.put(FloatFieldMapper.CONTENT_TYPE, new FloatFieldMapper.TypeParser());
mapperParsers.put(DoubleFieldMapper.CONTENT_TYPE, new DoubleFieldMapper.TypeParser());
mapperParsers.put(BooleanFieldMapper.CONTENT_TYPE, new BooleanFieldMapper.TypeParser());
mapperParsers.put(BinaryFieldMapper.CONTENT_TYPE, new BinaryFieldMapper.TypeParser());
mapperParsers.put(DateFieldMapper.CONTENT_TYPE, new DateFieldMapper.TypeParser());
mapperParsers.put(IpFieldMapper.CONTENT_TYPE, new IpFieldMapper.TypeParser());
mapperParsers.put(StringFieldMapper.CONTENT_TYPE, new StringFieldMapper.TypeParser());
mapperParsers.put(TokenCountFieldMapper.CONTENT_TYPE, new TokenCountFieldMapper.TypeParser());
mapperParsers.put(ObjectMapper.CONTENT_TYPE, new ObjectMapper.TypeParser());
mapperParsers.put(ObjectMapper.NESTED_CONTENT_TYPE, new ObjectMapper.TypeParser());
mapperParsers.put(TypeParsers.MULTI_FIELD_CONTENT_TYPE, TypeParsers.multiFieldConverterTypeParser);
mapperParsers.put(CompletionFieldMapper.CONTENT_TYPE, new CompletionFieldMapper.TypeParser());
mapperParsers.put(GeoPointFieldMapper.CONTENT_TYPE, new GeoPointFieldMapper.TypeParser());
return mapperParsers;
}
示例5: configure
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
@Override
protected void configure(RootObjectMapper.Builder builder) {
builder
.add(new DateFieldMapper.Builder("dateTime"))
.add(new FloatFieldMapper.Builder("temperature"))
.add(new FloatFieldMapper.Builder("windSpeed"))
.add(new FloatFieldMapper.Builder("stationPressure"))
.add(new StringFieldMapper.Builder("skyCondition"))
.add(new ObjectMapper.Builder("station")
.add(new StringFieldMapper.Builder("wban"))
.add(new StringFieldMapper.Builder("name"))
.add(new StringFieldMapper.Builder("state"))
.add(new StringFieldMapper.Builder("location"))
.add(new GeoPointFieldMapper.Builder("coordinates")
.enableLatLon(true)
.enableGeoHash(false))
.nested(ObjectMapper.Nested.newNested(true, false)));
}
示例6: isValidField
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
private boolean isValidField(MappedFieldType fieldType) {
// must be a string
if (!(fieldType instanceof StringFieldMapper.StringFieldType)) {
return false;
}
// and must be indexed
if (fieldType.indexOptions() == IndexOptions.NONE) {
return false;
}
return true;
}
示例7: BaseGeoPointFieldMapper
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
protected BaseGeoPointFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings,
ContentPath.Type pathType, DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper, StringFieldMapper geoHashMapper,
MultiFields multiFields, Explicit<Boolean> ignoreMalformed, CopyTo copyTo) {
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
this.pathType = pathType;
this.latMapper = latMapper;
this.lonMapper = lonMapper;
this.geoHashMapper = geoHashMapper;
this.ignoreMalformed = ignoreMalformed;
}
示例8: build
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
@Override
public GeoPointFieldMapper build(BuilderContext context, String simpleName, MappedFieldType fieldType,
MappedFieldType defaultFieldType, Settings indexSettings, ContentPath.Type pathType, DoubleFieldMapper latMapper,
DoubleFieldMapper lonMapper, StringFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
CopyTo copyTo) {
fieldType.setTokenized(false);
if (context.indexCreatedVersion().before(Version.V_2_3_0)) {
fieldType.setNumericPrecisionStep(GeoPointField.PRECISION_STEP);
fieldType.setNumericType(FieldType.NumericType.LONG);
}
setupFieldType(context);
return new GeoPointFieldMapper(simpleName, fieldType, defaultFieldType, indexSettings, pathType, latMapper, lonMapper,
geoHashMapper, multiFields, ignoreMalformed, copyTo);
}
示例9: build
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
@Override
public GeoPointFieldMapperLegacy build(BuilderContext context, String simpleName, MappedFieldType fieldType,
MappedFieldType defaultFieldType, Settings indexSettings, ContentPath.Type pathType, DoubleFieldMapper latMapper,
DoubleFieldMapper lonMapper, StringFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
CopyTo copyTo) {
fieldType.setTokenized(false);
setupFieldType(context);
fieldType.setHasDocValues(false);
defaultFieldType.setHasDocValues(false);
return new GeoPointFieldMapperLegacy(simpleName, fieldType, defaultFieldType, indexSettings, pathType, latMapper, lonMapper,
geoHashMapper, multiFields, ignoreMalformed, coerce(context), copyTo);
}
示例10: GeoPointFieldMapperLegacy
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
public GeoPointFieldMapperLegacy(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings,
ContentPath.Type pathType, DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper,
StringFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
Explicit<Boolean> coerce, CopyTo copyTo) {
super(simpleName, fieldType, defaultFieldType, indexSettings, pathType, latMapper, lonMapper, geoHashMapper, multiFields,
ignoreMalformed, copyTo);
this.coerce = coerce;
}
示例11: toFieldDataTermsQuery
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
private final Query toFieldDataTermsQuery(MappedFieldType fieldType, IndexFieldData fieldData,
byte[] encodedTerms, long cacheKey) {
Query query = null;
if (fieldType instanceof NumberFieldMapper.NumberFieldType) {
query = FieldDataTermsQuery.newLongs(encodedTerms, (IndexNumericFieldData) fieldData, cacheKey);
} else if (fieldType instanceof StringFieldMapper.StringFieldType) {
query = FieldDataTermsQuery.newBytes(encodedTerms, fieldData, cacheKey);
} else {
throw new ElasticsearchParseException("[fielddata_terms] query does not support field data type " + fieldType.fieldDataType().getType());
}
return query;
}
示例12: build
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
@Override
public OntologyMapper build(BuilderContext context) {
ContentPath.Type origPathType = context.path().pathType();
context.path().pathType(pathType);
Map<String, FieldMapper<String>> fieldMappers = Maps.newHashMap();
context.path().add(name);
if (propertyBuilders != null) {
for (String property : propertyBuilders.keySet()) {
StringFieldMapper sfm = propertyBuilders.get(property).build(context);
fieldMappers.put(sfm.names().indexName(), sfm);
}
}
// Initialise field mappers for the pre-defined fields
for (FieldMappings mapping : ontologySettings.getFieldMappings()) {
if (!fieldMappers.containsKey(context.path().fullPathAsText(mapping.getFieldName()))) {
StringFieldMapper mapper = MapperBuilders.stringField(mapping.getFieldName())
.store(true)
.index(true)
.tokenized(!mapping.isUriField())
.build(context);
fieldMappers.put(mapper.names().indexName(), mapper);
}
}
context.path().remove(); // remove name
context.path().pathType(origPathType);
return new OntologyMapper(buildNames(context), fieldType, docValues, indexAnalyzer, searchAnalyzer,
postingsProvider, docValuesProvider,
similarity, fieldDataSettings, context.indexSettings(),
new MultiFields.Builder().build(this, context),
ontologySettings, fieldMappers, threadPool);
}
示例13: parse
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
/**
* Parse the mapping definition for the ontology type.
*
* @param name the field name
* @param node the JSON node holding the mapping definitions.
* @param parserContext the parser context object.
* @return a Builder for an OntologyMapper.
*/
@SuppressWarnings("unchecked")
@Override
public Builder parse(String name, Map<String, Object> node, ParserContext parserContext)
throws MapperParsingException {
OntologySettings ontologySettings = null;
Builder builder = new Builder(name, threadPool);
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext(); ) {
Entry<String, Object> entry = iterator.next();
if (entry.getKey().equals(OntologySettings.ONTOLOGY_SETTINGS_KEY)) {
ontologySettings = new OntologySettingsBuilder()
.settingsNode((Map<String, Object>) entry.getValue())
.build();
iterator.remove();
} else if (entry.getKey().equals(ONTOLOGY_PROPERTIES)) {
Map<String, StringFieldMapper.Builder> builders = parseProperties((Map<String, Object>) entry.getValue(), parserContext);
builder.propertyBuilders(builders);
iterator.remove();
}
}
if (ontologySettings == null) {
throw new MapperParsingException("No ontology settings supplied");
} else if (StringUtils.isBlank(ontologySettings.getOntologyUri())
&& StringUtils.isBlank(ontologySettings.getOlsBaseUrl())) {
throw new MapperParsingException("No ontology URI or OLS details supplied");
} else {
builder = builder.ontologySettings(ontologySettings);
}
return builder;
}
示例14: parseProperties
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
private Map<String, StringFieldMapper.Builder> parseProperties(Map<String, Object> propertiesNode, ParserContext parserContext) {
Map<String, StringFieldMapper.Builder> propertyMap = new HashMap<>();
for (Iterator<Map.Entry<String, Object>> iterator = propertiesNode.entrySet().iterator(); iterator.hasNext(); ) {
Entry<String, Object> entry = iterator.next();
String name = entry.getKey();
@SuppressWarnings("unchecked")
Mapper.Builder builder = new StringFieldMapper.TypeParser().parse(entry.getKey(), (Map<String, Object>) entry.getValue(), parserContext);
propertyMap.put(name, (StringFieldMapper.Builder) builder);
}
return propertyMap;
}
示例15: build
import org.elasticsearch.index.mapper.core.StringFieldMapper; //导入依赖的package包/类
@Override
public OntologyMapper build(BuilderContext context) {
ContentPath.Type origPathType = context.path().pathType();
context.path().pathType(pathType);
Map<String, StringFieldMapper> fieldMappers = new HashMap<>();
context.path().add(name);
if (propertyBuilders != null) {
for (String property : propertyBuilders.keySet()) {
StringFieldMapper sfm = propertyBuilders.get(property).build(context);
fieldMappers.put(sfm.fieldType().names().indexName(), sfm);
}
}
// Initialise field mappers for the pre-defined fields
for (FieldMappings mapping : ontologySettings.getFieldMappings()) {
if (!fieldMappers.containsKey(context.path().fullPathAsText(mapping.getFieldName()))) {
StringFieldMapper mapper = MapperBuilders.stringField(mapping.getFieldName())
.store(true)
.index(true)
.tokenized(!mapping.isUriField())
.includeInAll(true)
.build(context);
fieldMappers.put(mapper.fieldType().names().indexName(), mapper);
}
}
context.path().remove(); // remove name
context.path().pathType(origPathType);
setupFieldType(context);
return new OntologyMapper(name, fieldType, defaultFieldType, context.indexSettings(),
multiFieldsBuilder.build(this, context),
ontologySettings, fieldMappers);
}