本文整理汇总了Java中org.elasticsearch.index.mapper.ParseContext.id方法的典型用法代码示例。如果您正苦于以下问题:Java ParseContext.id方法的具体用法?Java ParseContext.id怎么用?Java ParseContext.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.index.mapper.ParseContext
的用法示例。
在下文中一共展示了ParseContext.id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseCreateField
import org.elasticsearch.index.mapper.ParseContext; //导入方法依赖的package包/类
@Override
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException, AlreadyExpiredException {
if (enabledState.enabled && !context.sourceToParse().flyweight()) {
long ttl = context.sourceToParse().ttl();
if (ttl <= 0 && defaultTTL > 0) { // no ttl provided so we use the default value
ttl = defaultTTL;
context.sourceToParse().ttl(ttl);
}
if (ttl > 0) { // a ttl has been provided either externally or in the _source
long timestamp = context.sourceToParse().timestamp();
long expire = new Date(timestamp + ttl).getTime();
long now = System.currentTimeMillis();
// there is not point indexing already expired doc
if (context.sourceToParse().origin() == SourceToParse.Origin.PRIMARY && now >= expire) {
throw new AlreadyExpiredException(context.index(), context.type(), context.id(), timestamp, ttl, now);
}
// the expiration timestamp (timestamp + ttl) is set as field
fields.add(new LongFieldMapper.CustomLongNumericField(expire, fieldType()));
}
}
}
示例2: parseCreateField
import org.elasticsearch.index.mapper.ParseContext; //导入方法依赖的package包/类
@Override
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
XContentParser parser = context.parser();
if (parser.currentName() != null && parser.currentName().equals(Defaults.NAME) && parser.currentToken().isValue()) {
// we are in the parse Phase
String id = parser.text();
if (context.id() != null && !context.id().equals(id)) {
throw new MapperParsingException("Provided id [" + context.id() + "] does not match the content one [" + id + "]");
}
context.id(id);
} // else we are in the pre/post parse phase
if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) {
fields.add(new Field(fieldType().names().indexName(), context.id(), fieldType()));
}
if (fieldType().hasDocValues()) {
fields.add(new BinaryDocValuesField(fieldType().names().indexName(), new BytesRef(context.id())));
}
}
示例3: preParse
import org.elasticsearch.index.mapper.ParseContext; //导入方法依赖的package包/类
@Override
public void preParse(ParseContext context) throws IOException {
if (context.sourceToParse().id() != null) {
context.id(context.sourceToParse().id());
super.parse(context);
}
}
示例4: postParse
import org.elasticsearch.index.mapper.ParseContext; //导入方法依赖的package包/类
@Override
public void postParse(ParseContext context) throws IOException {
if (context.id() == null && !context.sourceToParse().flyweight()) {
throw new MapperParsingException("No id found while parsing the content source");
}
// it either get built in the preParse phase, or get parsed...
}
示例5: preParse
import org.elasticsearch.index.mapper.ParseContext; //导入方法依赖的package包/类
@Override
public void preParse(ParseContext context) throws IOException {
// if we have the id provided, fill it, and parse now
if (context.sourceToParse().id() != null) {
context.id(context.sourceToParse().id());
super.parse(context);
}
}