Java Code Examples for org.elasticsearch.common.lucene.uid.Versions#loadVersion()
The following examples show how to use
org.elasticsearch.common.lucene.uid.Versions#loadVersion() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VersionFetchSubPhase.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public void hitExecute(SearchContext context, HitContext hitContext) { // it might make sense to cache the TermDocs on a shared fetch context and just skip here) // it is going to mean we work on the high level multi reader and not the lower level reader as is // the case below... long version; try { BytesRef uid = Uid.createUidAsBytes(hitContext.hit().type(), hitContext.hit().id()); version = Versions.loadVersion( hitContext.readerContext().reader(), new Term(UidFieldMapper.NAME, uid) ); } catch (IOException e) { throw new ElasticsearchException("Could not query index for _version", e); } if (version < 0) { version = -1; } hitContext.hit().version(version); }
Example 2
Source File: IndicesTTLService.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void collect(int doc) { try { FieldsVisitor fieldsVisitor = new FieldsVisitor(false); context.reader().document(doc, fieldsVisitor); Uid uid = fieldsVisitor.uid(); final long version = Versions.loadVersion(context.reader(), new Term(UidFieldMapper.NAME, uid.toBytesRef())); docsToPurge.add(new DocToPurge(uid.type(), uid.id(), version, fieldsVisitor.routing())); } catch (Exception e) { logger.trace("failed to collect doc", e); } }
Example 3
Source File: DLBasedEngine.java From Elasticsearch with Apache License 2.0 | 4 votes |
private long loadCurrentVersionFromIndex(Term uid) throws IOException { try (final Searcher searcher = acquireSearcher("load_version", false)) { return Versions.loadVersion(searcher.reader(), uid); } }
Example 4
Source File: InternalEngine.java From Elasticsearch with Apache License 2.0 | 4 votes |
private long loadCurrentVersionFromIndex(Term uid) throws IOException { try (final Searcher searcher = acquireSearcher("load_version", false)) { return Versions.loadVersion(searcher.reader(), uid); } }