本文整理汇总了Java中org.elasticsearch.common.xcontent.XContentParser.Token.FIELD_NAME属性的典型用法代码示例。如果您正苦于以下问题:Java Token.FIELD_NAME属性的具体用法?Java Token.FIELD_NAME怎么用?Java Token.FIELD_NAME使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.elasticsearch.common.xcontent.XContentParser.Token
的用法示例。
在下文中一共展示了Token.FIELD_NAME属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseOption
protected static Option parseOption(XContentParser parser) throws IOException {
Token token;
String currentFieldName = null;
Option option = new Option();
while ((token = parser.nextToken()) != Token.END_OBJECT) {
if (token == Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if ("text".equals(currentFieldName)) {
option.text = parser.text();
} else if ("freq".equals(currentFieldName)) {
option.freq = parser.longValue();
} else if ("score".equals(currentFieldName)) {
option.score = parser.floatValue();
}
}
}
return option;
}
示例2: parseOption
protected static Option parseOption(XContentParser parser) throws IOException {
Token token;
String currentFieldName = null;
Option option = new Option();
while ((token = parser.nextToken()) != Token.END_OBJECT) {
if (token == Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if ("text".equals(currentFieldName)) {
option.text = parser.text();
} else if ("score".equals(currentFieldName)) {
option.score = parser.floatValue();
}
} else if (token == Token.START_OBJECT && "payload".equals(currentFieldName)) {
try (XContentBuilder docBuilder = XContentFactory.contentBuilder(XContentType.JSON)) {
docBuilder.copyCurrentStructure(parser);
option.payload = docBuilder.bytes().toUtf8();
}
}
}
return option;
}
示例3: parseOption
protected static Option parseOption(XContentParser parser) throws IOException {
Token token;
String currentFieldName = null;
Option option = new Option();
while ((token = parser.nextToken()) != Token.END_OBJECT) {
if (token == Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if ("text".equals(currentFieldName)) {
option.text = parser.text();
} else if ("collate".equals(currentFieldName)) {
option.collate = parser.booleanValue();
} else if ("score".equals(currentFieldName)) {
option.score = parser.floatValue();
} else if ("highlighted".equals(currentFieldName)) {
option.highlighted = parser.text();
}
}
}
return option;
}
示例4: parseRange
private static Range parseRange(XContentParser parser, QueryParseContext context) throws IOException {
String key = null;
String from = null;
String to = null;
String mask = null;
if (parser.currentToken() != Token.START_OBJECT) {
throw new ParsingException(parser.getTokenLocation(), "[ranges] must contain objects, but hit a " + parser.currentToken());
}
while (parser.nextToken() != Token.END_OBJECT) {
if (parser.currentToken() == Token.FIELD_NAME) {
continue;
}
if (RangeAggregator.Range.KEY_FIELD.match(parser.currentName())) {
key = parser.text();
} else if (RangeAggregator.Range.FROM_FIELD.match(parser.currentName())) {
from = parser.textOrNull();
} else if (RangeAggregator.Range.TO_FIELD.match(parser.currentName())) {
to = parser.textOrNull();
} else if (MASK_FIELD.match(parser.currentName())) {
mask = parser.text();
} else {
throw new ParsingException(parser.getTokenLocation(), "Unexpected ip range parameter: [" + parser.currentName() + "]");
}
}
if (mask != null) {
if (key == null) {
key = mask;
}
return new Range(key, mask);
} else {
return new Range(key, from, to);
}
}