本文整理了Java中org.elasticsearch.common.settings.Settings.fromXContent()
方法的一些代码示例,展示了Settings.fromXContent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.fromXContent()
方法的具体详情如下:
包路径:org.elasticsearch.common.settings.Settings
类名称:Settings
方法名:fromXContent
[英]Parsers the generated xcontent from Settings#toXContent(XContentBuilder,Params) into a new Settings object. Note this method requires the parser to either be positioned on a null token or on org.elasticsearch.common.xcontent.XContentParser.Token#START_OBJECT.
[中]将从设置#toXContent(XContentBuilder,Params)生成的xcontent解析为新的设置对象。注意:这个方法要求解析器要么定位在空标记上,要么定位在org上。弹性搜索。常见的非常重要。XContentParser。标记#开始_对象。
代码示例来源:origin: spring-projects/spring-data-elasticsearch
private Map<String, String> convertSettingResponse(String settingResponse, String indexName) {
ObjectMapper mapper = new ObjectMapper();
try {
Settings settings = Settings.fromXContent(XContentType.JSON.xContent().createParser(NamedXContentRegistry.EMPTY,
DeprecationHandler.THROW_UNSUPPORTED_OPERATION, settingResponse));
String prefix = indexName + ".settings.";
// Backwards compatibility. TODO Change to return Settings object.
Map<String, String> result = new HashMap<String, String>();
Set<String> keySet = settings.keySet();
for (String key : keySet) {
result.put(key.substring(prefix.length()), settings.get(key));
}
return result;
} catch (IOException e) {
throw new ElasticsearchException("Could not map alias response : " + settingResponse, e);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Parsers the generated xcontent from {@link Settings#toXContent(XContentBuilder, Params)} into a new Settings object.
* Note this method requires the parser to either be positioned on a null token or on
* {@link org.elasticsearch.common.xcontent.XContentParser.Token#START_OBJECT}.
*/
public static Settings fromXContent(XContentParser parser) throws IOException {
return fromXContent(parser, true, false);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private static void parseSettingsField(XContentParser parser, String currentIndexName, Map<String, Settings> indexToSettings,
Map<String, Settings> indexToDefaultSettings) throws IOException {
if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
switch (parser.currentName()) {
case "settings":
indexToSettings.put(currentIndexName, Settings.fromXContent(parser));
break;
case "defaults":
indexToDefaultSettings.put(currentIndexName, Settings.fromXContent(parser));
break;
default:
parser.skipChildren();
}
} else if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
parser.skipChildren();
}
parser.nextToken();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
keyBuilder.append('.');
fromXContent(parser, keyBuilder, builder, allowNullValues);
} else if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
List<String> list = new ArrayList<>();
代码示例来源:origin: org.elasticsearch/elasticsearch
} else if (token == XContentParser.Token.START_OBJECT) {
if ("settings".equals(currentFieldName)) {
builder.persistentSettings(Settings.fromXContent(parser));
} else if ("indices".equals(currentFieldName)) {
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
代码示例来源:origin: org.elasticsearch/elasticsearch
break;
case "settings":
indexSettings = Settings.fromXContent(parser);
break;
case "defaults":
indexDefaultSettings = Settings.fromXContent(parser);
break;
default:
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
/**
* Parsers the generated xcontent from {@link Settings#toXContent(XContentBuilder, Params)} into a new Settings object.
* Note this method requires the parser to either be positioned on a null token or on
* {@link org.elasticsearch.common.xcontent.XContentParser.Token#START_OBJECT}.
*/
public static Settings fromXContent(XContentParser parser) throws IOException {
return fromXContent(parser, true, false);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
if ("settings".equals(currentFieldName)) {
Settings.Builder templateSettingsBuilder = Settings.builder();
templateSettingsBuilder.put(Settings.fromXContent(parser));
templateSettingsBuilder.normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX);
builder.settings(templateSettingsBuilder.build());
代码示例来源:origin: org.elasticsearch/elasticsearch
throw new ElasticsearchParseException("failed to parse repository [{}], incompatible params", name);
settings = Settings.fromXContent(parser);
} else {
throw new ElasticsearchParseException("failed to parse repository [{}], unknown field [{}]",
代码示例来源:origin: org.elasticsearch/elasticsearch
} else if (token == XContentParser.Token.START_OBJECT) {
if (KEY_SETTINGS.equals(currentFieldName)) {
builder.settings(Settings.fromXContent(parser));
} else if (KEY_MAPPINGS.equals(currentFieldName)) {
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
代码示例来源:origin: org.elasticsearch/elasticsearch
private static Settings fromXContent(XContentParser parser, boolean allowNullValues, boolean validateEndOfStream) throws IOException {
if (parser.currentToken() == null) {
parser.nextToken();
}
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser::getTokenLocation);
Builder innerBuilder = Settings.builder();
StringBuilder currentKeyBuilder = new StringBuilder();
fromXContent(parser, currentKeyBuilder, innerBuilder, allowNullValues);
if (validateEndOfStream) {
// ensure we reached the end of the stream
XContentParser.Token lastToken = null;
try {
while (!parser.isClosed() && (lastToken = parser.nextToken()) == null) ;
} catch (Exception e) {
throw new ElasticsearchParseException(
"malformed, expected end of settings but encountered additional content starting at line number: [{}], "
+ "column number: [{}]",
e, parser.getTokenLocation().lineNumber, parser.getTokenLocation().columnNumber);
}
if (lastToken != null) {
throw new ElasticsearchParseException(
"malformed, expected end of settings but encountered additional content starting at line number: [{}], "
+ "column number: [{}]",
parser.getTokenLocation().lineNumber, parser.getTokenLocation().columnNumber);
}
}
return innerBuilder.build();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
private static void parseSettingsField(XContentParser parser, String currentIndexName, Map<String, Settings> indexToSettings,
Map<String, Settings> indexToDefaultSettings) throws IOException {
if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
switch (parser.currentName()) {
case "settings":
indexToSettings.put(currentIndexName, Settings.fromXContent(parser));
break;
case "defaults":
indexToDefaultSettings.put(currentIndexName, Settings.fromXContent(parser));
break;
default:
parser.skipChildren();
}
} else if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
parser.skipChildren();
}
parser.nextToken();
}
代码示例来源:origin: apache/servicemix-bundles
private static void parseSettingsField(XContentParser parser, String currentIndexName, Map<String, Settings> indexToSettings,
Map<String, Settings> indexToDefaultSettings) throws IOException {
if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
switch (parser.currentName()) {
case "settings":
indexToSettings.put(currentIndexName, Settings.fromXContent(parser));
break;
case "defaults":
indexToDefaultSettings.put(currentIndexName, Settings.fromXContent(parser));
break;
default:
parser.skipChildren();
}
} else if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
parser.skipChildren();
}
parser.nextToken();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
keyBuilder.append('.');
fromXContent(parser, keyBuilder, builder, allowNullValues);
} else if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
List<String> list = new ArrayList<>();
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
break;
case "settings":
indexSettings = Settings.fromXContent(parser);
break;
case "defaults":
indexDefaultSettings = Settings.fromXContent(parser);
break;
default:
代码示例来源:origin: apache/servicemix-bundles
break;
case "settings":
indexSettings = Settings.fromXContent(parser);
break;
case "defaults":
indexDefaultSettings = Settings.fromXContent(parser);
break;
default:
代码示例来源:origin: apache/servicemix-bundles
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
keyBuilder.append('.');
fromXContent(parser, keyBuilder, builder, allowNullValues);
} else if (parser.currentToken() == XContentParser.Token.START_ARRAY) {
List<String> list = new ArrayList<>();
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
throw new ElasticsearchParseException("failed to parse repository [{}], incompatible params", name);
settings = Settings.fromXContent(parser);
} else {
throw new ElasticsearchParseException("failed to parse repository [{}], unknown field [{}]", name, currentFieldName);
代码示例来源:origin: apache/servicemix-bundles
throw new ElasticsearchParseException("failed to parse repository [{}], incompatible params", name);
settings = Settings.fromXContent(parser);
} else {
throw new ElasticsearchParseException("failed to parse repository [{}], unknown field [{}]", name, currentFieldName);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
private static Settings fromXContent(XContentParser parser, boolean allowNullValues, boolean validateEndOfStream) throws IOException {
if (parser.currentToken() == null) {
parser.nextToken();
}
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser::getTokenLocation);
Builder innerBuilder = Settings.builder();
StringBuilder currentKeyBuilder = new StringBuilder();
fromXContent(parser, currentKeyBuilder, innerBuilder, allowNullValues);
if (validateEndOfStream) {
// ensure we reached the end of the stream
XContentParser.Token lastToken = null;
try {
while (!parser.isClosed() && (lastToken = parser.nextToken()) == null) ;
} catch (Exception e) {
throw new ElasticsearchParseException(
"malformed, expected end of settings but encountered additional content starting at line number: [{}], "
+ "column number: [{}]",
e, parser.getTokenLocation().lineNumber, parser.getTokenLocation().columnNumber);
}
if (lastToken != null) {
throw new ElasticsearchParseException(
"malformed, expected end of settings but encountered additional content starting at line number: [{}], "
+ "column number: [{}]",
parser.getTokenLocation().lineNumber, parser.getTokenLocation().columnNumber);
}
}
return innerBuilder.build();
}
内容来源于网络,如有侵权,请联系作者删除!