fix term vector api for missing payloads
This commit is contained in:
parent
f8a129961e
commit
f91fd3b9ed
|
@ -246,7 +246,7 @@ public class TermVectorResponse extends ActionResponse implements ToXContent {
|
|||
builder.field(FieldStrings.START_OFFSET, currentStartOffset[i]);
|
||||
builder.field(FieldStrings.END_OFFSET, currentEndOffset[i]);
|
||||
}
|
||||
if (curTerms.hasPayloads()) {
|
||||
if (curTerms.hasPayloads() && (currentPayloads[i] != null)) {
|
||||
builder.field(FieldStrings.PAYLOAD, currentPayloads[i]);
|
||||
}
|
||||
builder.endObject();
|
||||
|
@ -266,8 +266,12 @@ public class TermVectorResponse extends ActionResponse implements ToXContent {
|
|||
currentEndOffset[j] = posEnum.endOffset();
|
||||
}
|
||||
if (curTerms.hasPayloads()) {
|
||||
BytesRef curPaypoad = posEnum.getPayload();
|
||||
currentPayloads[j] = new BytesArray(curPaypoad.bytes, 0, curPaypoad.length);
|
||||
BytesRef curPayload = posEnum.getPayload();
|
||||
if (curPayload != null) {
|
||||
currentPayloads[j] = new BytesArray(curPayload.bytes, 0, curPayload.length);
|
||||
} else {
|
||||
currentPayloads[j] = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,6 +153,8 @@ final class TermVectorWriter {
|
|||
if (payload != null) {
|
||||
output.writeVInt(payload.length);
|
||||
output.writeBytes(payload.bytes, payload.offset, payload.length);
|
||||
} else {
|
||||
output.writeVInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue