don't return any id when doesn't exists
This commit is contained in:
parent
fb35b1c993
commit
efb3e97ce4
|
@ -248,8 +248,8 @@ public class TransportGetAction extends TransportShardSingleOperationAction<GetR
|
|||
continue;
|
||||
}
|
||||
UidField.DocIdAndVersion docIdAndVersion = UidField.loadDocIdAndVersion(reader, uid);
|
||||
// either -2 (its there, but no version associated), or an actual version
|
||||
if (docIdAndVersion.docId != -1) {
|
||||
// not null if it exists
|
||||
if (docIdAndVersion != null) {
|
||||
return docIdAndVersion;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class UidField extends AbstractField {
|
|||
try {
|
||||
uid = reader.termPositions(term);
|
||||
if (!uid.next()) {
|
||||
return new DocIdAndVersion(Lucene.NO_DOC, -1, reader);
|
||||
return null; // no doc
|
||||
}
|
||||
docId = uid.doc();
|
||||
uid.nextPosition();
|
||||
|
|
|
@ -67,6 +67,6 @@ public class UidFieldTests {
|
|||
writer.deleteDocuments(new Term("_uid", "1"));
|
||||
reader = reader.reopen();
|
||||
assertThat(UidField.loadVersion(reader, new Term("_uid", "1")), equalTo(-1l));
|
||||
assertThat(UidField.loadDocIdAndVersion(reader, new Term("_uid", "1")).version, equalTo(-1l));
|
||||
assertThat(UidField.loadDocIdAndVersion(reader, new Term("_uid", "1")), nullValue());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue