Rename "exists" to "found" in TermVector and Get responses

- Adds the "created" field to the index action response
- Reverses Delete class' notFound to Found to avoid double negative
This commit is contained in:
Lee Hinman 2014-01-02 13:31:49 -07:00
parent d23f640cd1
commit 2cb40fcb17
28 changed files with 85 additions and 92 deletions

View File

@ -170,7 +170,7 @@ Response:
"_index": "twitter",
"_type": "tweet",
"_version": 1,
"exists": true,
"found": true,
"term_vectors": {
"text": {
"field_statistics": {
@ -222,5 +222,3 @@ Response:
}
}
--------------------------------------------------

View File

@ -28,7 +28,7 @@
id: 1
realtime: 1
- is_true: exists
- is_true: found
- do:
catch: missing
@ -46,5 +46,4 @@
realtime: 0
refresh: 1
- is_true: exists
- is_true: found

View File

@ -23,22 +23,22 @@
- { _index: test_1, _type: test, _id: 2}
- { _index: test_1, _type: test, _id: 1}
- is_false: docs.0.exists
- is_false: docs.0.found
- match: { docs.0._index: test_2 }
- match: { docs.0._type: test }
- match: { docs.0._id: "1" }
- is_false: docs.1.exists
- is_false: docs.1.found
- match: { docs.1._index: test_1 }
- match: { docs.1._type: none }
- match: { docs.1._id: "1" }
- is_false: docs.2.exists
- is_false: docs.2.found
- match: { docs.2._index: test_1 }
- match: { docs.2._type: test }
- match: { docs.2._id: "2" }
- is_true: docs.3.exists
- is_true: docs.3.found
- match: { docs.3._index: test_1 }
- match: { docs.3._type: test }
- match: { docs.3._id: "1" }

View File

@ -25,22 +25,22 @@
- { _id: 2}
- { _id: 1}
- is_false: docs.0.exists
- is_false: docs.0.found
- match: { docs.0._index: test_2 }
- match: { docs.0._type: test }
- match: { docs.0._id: "1" }
- is_false: docs.1.exists
- is_false: docs.1.found
- match: { docs.1._index: test_1 }
- match: { docs.1._type: none }
- match: { docs.1._id: "1" }
- is_false: docs.2.exists
- is_false: docs.2.found
- match: { docs.2._index: test_1 }
- match: { docs.2._type: test }
- match: { docs.2._id: "2" }
- is_true: docs.3.exists
- is_true: docs.3.found
- match: { docs.3._index: test_1 }
- match: { docs.3._type: test }
- match: { docs.3._id: "1" }

View File

@ -17,7 +17,7 @@
docs:
- { _index: test_2, _type: test, _id: 1}
- is_false: docs.0.exists
- is_false: docs.0.found
- match: { docs.0._index: test_2 }
- match: { docs.0._type: test }
- match: { docs.0._id: "1" }
@ -29,8 +29,7 @@
docs:
- { _index: test_1, _type: test, _id: 1}
- is_true: docs.0.exists
- is_true: docs.0.found
- match: { docs.0._index: test_1 }
- match: { docs.0._type: test }
- match: { docs.0._id: "1" }

View File

@ -43,10 +43,9 @@
docs:
- { _index: test_1, _id: 1}
- is_true: docs.0.exists
- is_true: docs.0.found
- match: { docs.0._index: test_1 }
- match: { docs.0._type: test }
- match: { docs.0._id: "1" }
- match: { docs.0._version: 1 }
- match: { docs.0._source: { foo: bar }}

View File

@ -25,14 +25,14 @@
body:
ids: [1, 2]
- is_true: docs.0.exists
- is_true: docs.0.found
- match: { docs.0._index: test_1 }
- match: { docs.0._type: test }
- match: { docs.0._id: "1" }
- match: { docs.0._version: 1 }
- match: { docs.0._source: { foo: bar }}
- is_false: docs.1.exists
- is_false: docs.1.found
- match: { docs.1._index: test_1 }
- match: { docs.1._type: test }
- match: { docs.1._id: "2" }
@ -43,14 +43,14 @@
body:
ids: [1, 2]
- is_true: docs.0.exists
- is_true: docs.0.found
- match: { docs.0._index: test_1 }
- match: { docs.0._type: test }
- match: { docs.0._id: "1" }
- match: { docs.0._version: 1 }
- match: { docs.0._source: { foo: bar }}
- is_true: docs.1.exists
- is_true: docs.1.found
- match: { docs.1._index: test_1 }
- match: { docs.1._type: test_2 }
- match: { docs.1._id: "2" }
@ -70,4 +70,3 @@
mget:
index: test_1
body: {}

View File

@ -39,20 +39,19 @@
- { _id: 1, parent: 4, fields: [ _parent, _routing ] }
- { _id: 2, parent: 5, fields: [ _parent, _routing ] }
- is_false: docs.0.exists
- is_false: docs.1.exists
- is_false: docs.0.found
- is_false: docs.1.found
- is_true: docs.2.exists
- is_true: docs.2.found
- match: { docs.2._index: test_1 }
- match: { docs.2._type: test }
- match: { docs.2._id: "1" }
- match: { docs.2.fields._parent: "4" }
- match: { docs.2.fields._routing: "4" }
- is_true: docs.3.exists
- is_true: docs.3.found
- match: { docs.3._index: test_1 }
- match: { docs.3._type: test }
- match: { docs.3._id: "2" }
- match: { docs.3.fields._parent: "5" }
- match: { docs.3.fields._routing: "5" }

View File

@ -22,10 +22,10 @@
- { _id: 1, routing: 4 }
- { _id: 1, routing: 5 }
- is_false: docs.0.exists
- is_false: docs.1.exists
- is_false: docs.0.found
- is_false: docs.1.found
- is_true: docs.2.exists
- is_true: docs.2.found
- match: { docs.2._index: test_1 }
- match: { docs.2._type: test }
- match: { docs.2._id: "1" }

View File

@ -32,13 +32,12 @@
- { _id: 1, parent: 4 }
- { _id: 1, parent: 4, routing: 5 }
- is_false: docs.0.exists
- is_false: docs.1.exists
- is_false: docs.0.found
- is_false: docs.1.found
- is_true: docs.2.exists
- is_true: docs.2.found
- match: { docs.2._index: test_1 }
- match: { docs.2._type: test }
- match: { docs.2._id: "1" }
- match: { docs.2.fields._parent: "4" }
- match: { docs.2.fields._routing: "5" }

View File

@ -29,7 +29,7 @@
body:
ids: [1]
- is_false: docs.0.exists
- is_false: docs.0.found
- do:
mget:
@ -39,7 +39,7 @@
body:
ids: [1]
- is_true: docs.0.exists
- is_true: docs.0.found
- do:
mget:
@ -50,4 +50,4 @@
body:
ids: [1]
- is_true: docs.0.exists
- is_true: docs.0.found

View File

@ -422,7 +422,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
indexShard.delete(delete);
// update the request with the version so it will go to the replicas
deleteRequest.version(delete.version());
DeleteResponse deleteResponse = new DeleteResponse(deleteRequest.index(), deleteRequest.type(), deleteRequest.id(), delete.version(), delete.notFound());
DeleteResponse deleteResponse = new DeleteResponse(deleteRequest.index(), deleteRequest.type(), deleteRequest.id(), delete.version(), delete.found());
return new WriteResult(deleteResponse, deleteRequest.version(), null, null);
}

View File

@ -37,18 +37,18 @@ public class DeleteResponse extends ActionResponse {
private String id;
private String type;
private long version;
private boolean notFound;
private boolean found;
public DeleteResponse() {
}
public DeleteResponse(String index, String type, String id, long version, boolean notFound) {
public DeleteResponse(String index, String type, String id, long version, boolean found) {
this.index = index;
this.id = id;
this.type = type;
this.version = version;
this.notFound = notFound;
this.found = found;
}
/**
@ -82,8 +82,8 @@ public class DeleteResponse extends ActionResponse {
/**
* Returns <tt>true</tt> if there was no doc found to delete.
*/
public boolean isNotFound() {
return notFound;
public boolean isFound() {
return found;
}
@Override
@ -93,7 +93,7 @@ public class DeleteResponse extends ActionResponse {
type = in.readSharedString();
id = in.readString();
version = in.readLong();
notFound = in.readBoolean();
found = in.readBoolean();
}
@Override
@ -103,6 +103,6 @@ public class DeleteResponse extends ActionResponse {
out.writeSharedString(type);
out.writeString(id);
out.writeLong(version);
out.writeBoolean(notFound);
out.writeBoolean(found);
}
}

View File

@ -114,13 +114,13 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct
long version = Versions.MATCH_ANY;
boolean found = false;
for (ShardDeleteResponse deleteResponse : indexDeleteResponse.getResponses()) {
if (!deleteResponse.isNotFound()) {
if (deleteResponse.isFound()) {
version = deleteResponse.getVersion();
found = true;
break;
}
}
listener.onResponse(new DeleteResponse(request.index(), request.type(), request.id(), version, !found));
listener.onResponse(new DeleteResponse(request.index(), request.type(), request.id(), version, found));
}
@Override
@ -193,7 +193,7 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct
}
}
DeleteResponse response = new DeleteResponse(request.index(), request.type(), request.id(), delete.version(), delete.notFound());
DeleteResponse response = new DeleteResponse(request.index(), request.type(), request.id(), delete.version(), delete.found());
return new PrimaryResponse<DeleteResponse, DeleteRequest>(shardRequest.request, response, null);
}

View File

@ -31,35 +31,35 @@ import java.io.IOException;
public class ShardDeleteResponse extends ActionResponse {
private long version;
private boolean notFound;
private boolean found;
public ShardDeleteResponse() {
}
public ShardDeleteResponse(long version, boolean notFound) {
public ShardDeleteResponse(long version, boolean found) {
this.version = version;
this.notFound = notFound;
this.found = found;
}
public long getVersion() {
return version;
}
public boolean isNotFound() {
return notFound;
public boolean isFound() {
return found;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
version = in.readLong();
notFound = in.readBoolean();
found = in.readBoolean();
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeLong(version);
out.writeBoolean(notFound);
out.writeBoolean(found);
}
}

View File

@ -107,7 +107,7 @@ public class TransportShardDeleteAction extends TransportShardReplicationOperati
}
ShardDeleteResponse response = new ShardDeleteResponse(delete.version(), delete.notFound());
ShardDeleteResponse response = new ShardDeleteResponse(delete.version(), delete.found());
return new PrimaryResponse<ShardDeleteResponse, ShardDeleteRequest>(shardRequest.request, response, null);
}

View File

@ -68,7 +68,7 @@ public class TermVectorResponse extends ActionResponse implements ToXContent {
public static final XContentBuilderString _TYPE = new XContentBuilderString("_type");
public static final XContentBuilderString _ID = new XContentBuilderString("_id");
public static final XContentBuilderString _VERSION = new XContentBuilderString("_version");
public static final XContentBuilderString EXISTS = new XContentBuilderString("exists");
public static final XContentBuilderString FOUND = new XContentBuilderString("found");
public static final XContentBuilderString TERMS = new XContentBuilderString("terms");
public static final XContentBuilderString TERM_VECTORS = new XContentBuilderString("term_vectors");
@ -169,7 +169,7 @@ public class TermVectorResponse extends ActionResponse implements ToXContent {
builder.field(FieldStrings._TYPE, type);
builder.field(FieldStrings._ID, id);
builder.field(FieldStrings._VERSION, docVersion);
builder.field(FieldStrings.EXISTS, isExists());
builder.field(FieldStrings.FOUND, isExists());
if (!isExists()) {
builder.endObject();
return builder;

View File

@ -656,7 +656,7 @@ public interface Engine extends IndexShardComponent, CloseableComponent {
private long version = Versions.MATCH_ANY;
private VersionType versionType = VersionType.INTERNAL;
private Origin origin = Origin.PRIMARY;
private boolean notFound;
private boolean found;
private long startTime;
private long endTime;
@ -715,12 +715,12 @@ public interface Engine extends IndexShardComponent, CloseableComponent {
return this.versionType;
}
public boolean notFound() {
return this.notFound;
public boolean found() {
return this.found;
}
public Delete notFound(boolean notFound) {
this.notFound = notFound;
public Delete found(boolean found) {
this.found = found;
return this;
}

View File

@ -625,16 +625,16 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine {
if (currentVersion == Versions.NOT_FOUND) {
// doc does not exists and no prior deletes
delete.version(updatedVersion).notFound(true);
delete.version(updatedVersion).found(false);
Translog.Location translogLocation = translog.add(new Translog.Delete(delete));
versionMap.put(versionKey, new VersionValue(updatedVersion, true, threadPool.estimatedTimeInMillis(), translogLocation));
} else if (versionValue != null && versionValue.delete()) {
// a "delete on delete", in this case, we still increment the version, log it, and return that version
delete.version(updatedVersion).notFound(true);
delete.version(updatedVersion).found(false);
Translog.Location translogLocation = translog.add(new Translog.Delete(delete));
versionMap.put(versionKey, new VersionValue(updatedVersion, true, threadPool.estimatedTimeInMillis(), translogLocation));
} else {
delete.version(updatedVersion);
delete.version(updatedVersion).found(true);
writer.deleteDocuments(delete.uid());
Translog.Location translogLocation = translog.add(new Translog.Delete(delete));
versionMap.put(versionKey, new VersionValue(updatedVersion, true, threadPool.estimatedTimeInMillis(), translogLocation));

View File

@ -202,12 +202,12 @@ public class GetResult implements Streamable, Iterable<GetField>, ToXContent {
static final XContentBuilderString _TYPE = new XContentBuilderString("_type");
static final XContentBuilderString _ID = new XContentBuilderString("_id");
static final XContentBuilderString _VERSION = new XContentBuilderString("_version");
static final XContentBuilderString EXISTS = new XContentBuilderString("exists");
static final XContentBuilderString FOUND = new XContentBuilderString("found");
static final XContentBuilderString FIELDS = new XContentBuilderString("fields");
}
public XContentBuilder toXContentEmbedded(XContentBuilder builder, Params params) throws IOException {
builder.field(Fields.EXISTS, exists);
builder.field(Fields.FOUND, exists);
if (source != null) {
RestXContentBuilder.restDocumentSource(source, builder, params);
@ -242,7 +242,7 @@ public class GetResult implements Streamable, Iterable<GetField>, ToXContent {
builder.field(Fields._INDEX, index);
builder.field(Fields._TYPE, type);
builder.field(Fields._ID, id);
builder.field(Fields.EXISTS, false);
builder.field(Fields.FOUND, false);
builder.endObject();
} else {
builder.startObject();

View File

@ -127,12 +127,12 @@ public class RestBulkAction extends BaseRestHandler {
} else {
if (itemResponse.getResponse() instanceof DeleteResponse) {
DeleteResponse deleteResponse = itemResponse.getResponse();
if (deleteResponse.isNotFound()) {
builder.field(Fields.STATUS, RestStatus.NOT_FOUND.getStatus());
} else {
if (deleteResponse.isFound()) {
builder.field(Fields.STATUS, RestStatus.OK.getStatus());
} else {
builder.field(Fields.STATUS, RestStatus.NOT_FOUND.getStatus());
}
builder.field(Fields.FOUND, !deleteResponse.isNotFound());
builder.field(Fields.FOUND, deleteResponse.isFound());
} else if (itemResponse.getResponse() instanceof IndexResponse) {
IndexResponse indexResponse = itemResponse.getResponse();
if (indexResponse.isCreated()) {

View File

@ -80,14 +80,14 @@ public class RestDeleteAction extends BaseRestHandler {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject()
.field(Fields.FOUND, !result.isNotFound())
.field(Fields.FOUND, result.isFound())
.field(Fields._INDEX, result.getIndex())
.field(Fields._TYPE, result.getType())
.field(Fields._ID, result.getId())
.field(Fields._VERSION, result.getVersion())
.endObject();
RestStatus status = OK;
if (result.isNotFound()) {
if (!result.isFound()) {
status = NOT_FOUND;
}
channel.sendResponse(new XContentRestResponse(request, status, builder));

View File

@ -112,7 +112,8 @@ public class RestIndexAction extends BaseRestHandler {
.field(Fields._INDEX, response.getIndex())
.field(Fields._TYPE, response.getType())
.field(Fields._ID, response.getId())
.field(Fields._VERSION, response.getVersion());
.field(Fields._VERSION, response.getVersion())
.field(Fields.CREATED, response.isCreated());
builder.endObject();
RestStatus status = OK;
if (response.isCreated()) {
@ -140,7 +141,7 @@ public class RestIndexAction extends BaseRestHandler {
static final XContentBuilderString _TYPE = new XContentBuilderString("_type");
static final XContentBuilderString _ID = new XContentBuilderString("_id");
static final XContentBuilderString _VERSION = new XContentBuilderString("_version");
static final XContentBuilderString MATCHES = new XContentBuilderString("matches");
static final XContentBuilderString CREATED = new XContentBuilderString("created");
}
}

View File

@ -134,7 +134,7 @@ public class GetTermVectorCheckDocFreqTests extends ElasticsearchIntegrationTest
String utf8 = bytesStream.bytes().toUtf8();
String expectedString = "{\"_index\":\"test\",\"_type\":\"type1\",\"_id\":\""
+ i
+ "\",\"_version\":1,\"exists\":true,\"term_vectors\":{\"field\":{\"terms\":{\"brown\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":2,\"start_offset\":10,\"end_offset\":15,\"payload\":\"d29yZA==\"}]},\"dog\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":8,\"start_offset\":40,\"end_offset\":43,\"payload\":\"d29yZA==\"}]},\"fox\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":3,\"start_offset\":16,\"end_offset\":19,\"payload\":\"d29yZA==\"}]},\"jumps\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":4,\"start_offset\":20,\"end_offset\":25,\"payload\":\"d29yZA==\"}]},\"lazy\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":7,\"start_offset\":35,\"end_offset\":39,\"payload\":\"d29yZA==\"}]},\"over\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":5,\"start_offset\":26,\"end_offset\":30,\"payload\":\"d29yZA==\"}]},\"quick\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":1,\"start_offset\":4,\"end_offset\":9,\"payload\":\"d29yZA==\"}]},\"the\":{\"doc_freq\":15,\"ttf\":30,\"term_freq\":2,\"tokens\":[{\"position\":0,\"start_offset\":0,\"end_offset\":3,\"payload\":\"d29yZA==\"},{\"position\":6,\"start_offset\":31,\"end_offset\":34,\"payload\":\"d29yZA==\"}]}}}}}";
+ "\",\"_version\":1,\"found\":true,\"term_vectors\":{\"field\":{\"terms\":{\"brown\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":2,\"start_offset\":10,\"end_offset\":15,\"payload\":\"d29yZA==\"}]},\"dog\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":8,\"start_offset\":40,\"end_offset\":43,\"payload\":\"d29yZA==\"}]},\"fox\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":3,\"start_offset\":16,\"end_offset\":19,\"payload\":\"d29yZA==\"}]},\"jumps\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":4,\"start_offset\":20,\"end_offset\":25,\"payload\":\"d29yZA==\"}]},\"lazy\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":7,\"start_offset\":35,\"end_offset\":39,\"payload\":\"d29yZA==\"}]},\"over\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":5,\"start_offset\":26,\"end_offset\":30,\"payload\":\"d29yZA==\"}]},\"quick\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":1,\"start_offset\":4,\"end_offset\":9,\"payload\":\"d29yZA==\"}]},\"the\":{\"doc_freq\":15,\"ttf\":30,\"term_freq\":2,\"tokens\":[{\"position\":0,\"start_offset\":0,\"end_offset\":3,\"payload\":\"d29yZA==\"},{\"position\":6,\"start_offset\":31,\"end_offset\":34,\"payload\":\"d29yZA==\"}]}}}}}";
assertThat(utf8, equalTo(expectedString));
}
@ -190,7 +190,7 @@ public class GetTermVectorCheckDocFreqTests extends ElasticsearchIntegrationTest
String utf8 = bytesStream.bytes().toUtf8();
String expectedString = "{\"_index\":\"test\",\"_type\":\"type1\",\"_id\":\""
+ i
+ "\",\"_version\":1,\"exists\":true,\"term_vectors\":{\"field\":{\"field_statistics\":{\"sum_doc_freq\":120,\"doc_count\":15,\"sum_ttf\":135},\"terms\":{\"brown\":{\"term_freq\":1,\"tokens\":[{\"position\":2,\"start_offset\":10,\"end_offset\":15,\"payload\":\"d29yZA==\"}]},\"dog\":{\"term_freq\":1,\"tokens\":[{\"position\":8,\"start_offset\":40,\"end_offset\":43,\"payload\":\"d29yZA==\"}]},\"fox\":{\"term_freq\":1,\"tokens\":[{\"position\":3,\"start_offset\":16,\"end_offset\":19,\"payload\":\"d29yZA==\"}]},\"jumps\":{\"term_freq\":1,\"tokens\":[{\"position\":4,\"start_offset\":20,\"end_offset\":25,\"payload\":\"d29yZA==\"}]},\"lazy\":{\"term_freq\":1,\"tokens\":[{\"position\":7,\"start_offset\":35,\"end_offset\":39,\"payload\":\"d29yZA==\"}]},\"over\":{\"term_freq\":1,\"tokens\":[{\"position\":5,\"start_offset\":26,\"end_offset\":30,\"payload\":\"d29yZA==\"}]},\"quick\":{\"term_freq\":1,\"tokens\":[{\"position\":1,\"start_offset\":4,\"end_offset\":9,\"payload\":\"d29yZA==\"}]},\"the\":{\"term_freq\":2,\"tokens\":[{\"position\":0,\"start_offset\":0,\"end_offset\":3,\"payload\":\"d29yZA==\"},{\"position\":6,\"start_offset\":31,\"end_offset\":34,\"payload\":\"d29yZA==\"}]}}}}}";
+ "\",\"_version\":1,\"found\":true,\"term_vectors\":{\"field\":{\"field_statistics\":{\"sum_doc_freq\":120,\"doc_count\":15,\"sum_ttf\":135},\"terms\":{\"brown\":{\"term_freq\":1,\"tokens\":[{\"position\":2,\"start_offset\":10,\"end_offset\":15,\"payload\":\"d29yZA==\"}]},\"dog\":{\"term_freq\":1,\"tokens\":[{\"position\":8,\"start_offset\":40,\"end_offset\":43,\"payload\":\"d29yZA==\"}]},\"fox\":{\"term_freq\":1,\"tokens\":[{\"position\":3,\"start_offset\":16,\"end_offset\":19,\"payload\":\"d29yZA==\"}]},\"jumps\":{\"term_freq\":1,\"tokens\":[{\"position\":4,\"start_offset\":20,\"end_offset\":25,\"payload\":\"d29yZA==\"}]},\"lazy\":{\"term_freq\":1,\"tokens\":[{\"position\":7,\"start_offset\":35,\"end_offset\":39,\"payload\":\"d29yZA==\"}]},\"over\":{\"term_freq\":1,\"tokens\":[{\"position\":5,\"start_offset\":26,\"end_offset\":30,\"payload\":\"d29yZA==\"}]},\"quick\":{\"term_freq\":1,\"tokens\":[{\"position\":1,\"start_offset\":4,\"end_offset\":9,\"payload\":\"d29yZA==\"}]},\"the\":{\"term_freq\":2,\"tokens\":[{\"position\":0,\"start_offset\":0,\"end_offset\":3,\"payload\":\"d29yZA==\"},{\"position\":6,\"start_offset\":31,\"end_offset\":34,\"payload\":\"d29yZA==\"}]}}}}}";
assertThat(utf8, equalTo(expectedString));
}
@ -249,7 +249,7 @@ public class GetTermVectorCheckDocFreqTests extends ElasticsearchIntegrationTest
String utf8 = bytesStream.bytes().toUtf8();
String expectedString = "{\"_index\":\"test\",\"_type\":\"type1\",\"_id\":\""
+ i
+ "\",\"_version\":1,\"exists\":true,\"term_vectors\":{\"field\":{\"field_statistics\":{\"sum_doc_freq\":120,\"doc_count\":15,\"sum_ttf\":135},\"terms\":{\"brown\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":2,\"start_offset\":10,\"end_offset\":15,\"payload\":\"d29yZA==\"}]},\"dog\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":8,\"start_offset\":40,\"end_offset\":43,\"payload\":\"d29yZA==\"}]},\"fox\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":3,\"start_offset\":16,\"end_offset\":19,\"payload\":\"d29yZA==\"}]},\"jumps\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":4,\"start_offset\":20,\"end_offset\":25,\"payload\":\"d29yZA==\"}]},\"lazy\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":7,\"start_offset\":35,\"end_offset\":39,\"payload\":\"d29yZA==\"}]},\"over\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":5,\"start_offset\":26,\"end_offset\":30,\"payload\":\"d29yZA==\"}]},\"quick\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":1,\"start_offset\":4,\"end_offset\":9,\"payload\":\"d29yZA==\"}]},\"the\":{\"doc_freq\":15,\"ttf\":30,\"term_freq\":2,\"tokens\":[{\"position\":0,\"start_offset\":0,\"end_offset\":3,\"payload\":\"d29yZA==\"},{\"position\":6,\"start_offset\":31,\"end_offset\":34,\"payload\":\"d29yZA==\"}]}}}}}";
+ "\",\"_version\":1,\"found\":true,\"term_vectors\":{\"field\":{\"field_statistics\":{\"sum_doc_freq\":120,\"doc_count\":15,\"sum_ttf\":135},\"terms\":{\"brown\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":2,\"start_offset\":10,\"end_offset\":15,\"payload\":\"d29yZA==\"}]},\"dog\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":8,\"start_offset\":40,\"end_offset\":43,\"payload\":\"d29yZA==\"}]},\"fox\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":3,\"start_offset\":16,\"end_offset\":19,\"payload\":\"d29yZA==\"}]},\"jumps\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":4,\"start_offset\":20,\"end_offset\":25,\"payload\":\"d29yZA==\"}]},\"lazy\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":7,\"start_offset\":35,\"end_offset\":39,\"payload\":\"d29yZA==\"}]},\"over\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":5,\"start_offset\":26,\"end_offset\":30,\"payload\":\"d29yZA==\"}]},\"quick\":{\"doc_freq\":15,\"ttf\":15,\"term_freq\":1,\"tokens\":[{\"position\":1,\"start_offset\":4,\"end_offset\":9,\"payload\":\"d29yZA==\"}]},\"the\":{\"doc_freq\":15,\"ttf\":30,\"term_freq\":2,\"tokens\":[{\"position\":0,\"start_offset\":0,\"end_offset\":3,\"payload\":\"d29yZA==\"},{\"position\":6,\"start_offset\":31,\"end_offset\":34,\"payload\":\"d29yZA==\"}]}}}}}";
assertThat(utf8, equalTo(expectedString));
}

View File

@ -147,7 +147,7 @@ public class GetActionTests extends ElasticsearchIntegrationTest {
assertThat(response.getSourceAsMap().get("field2").toString(), equalTo("value2_2"));
DeleteResponse deleteResponse = client().prepareDelete("test", "type1", "1").execute().actionGet();
assertThat(deleteResponse.isNotFound(), equalTo(false));
assertThat(deleteResponse.isFound(), equalTo(true));
response = client().prepareGet("test", "type1", "1").execute().actionGet();
assertThat(response.isExists(), equalTo(false));

View File

@ -166,7 +166,7 @@ public class SimpleNestedTests extends ElasticsearchIntegrationTest {
// check delete, so all is gone...
DeleteResponse deleteResponse = client().prepareDelete("test", "type1", "2").execute().actionGet();
assertThat(deleteResponse.isNotFound(), equalTo(false));
assertThat(deleteResponse.isFound(), equalTo(true));
// flush, so we fetch it from the index (as see that we filter nested docs)
flush();

View File

@ -336,7 +336,7 @@ public class ConcurrentPercolatorTests extends ElasticsearchIntegrationTest {
DeleteResponse response = client().prepareDelete("index", PercolatorService.TYPE_NAME, id)
.execute().actionGet();
assertThat(response.getId(), equalTo(id));
assertThat("doc[" + id + "] should have been deleted, but isn't", response.isNotFound(), equalTo(false));
assertThat("doc[" + id + "] should have been deleted, but isn't", response.isFound(), equalTo(true));
} else {
String id = Integer.toString(idGen.getAndIncrement());
IndexResponse response = client().prepareIndex("index", PercolatorService.TYPE_NAME, id)

View File

@ -49,7 +49,7 @@ public class SimpleVersioningTests extends ElasticsearchIntegrationTest {
// Note - external version doesn't throw version conflicts on deletes of non existent records. This is different from internal versioning
DeleteResponse deleteResponse = client().prepareDelete("test", "type", "1").setVersion(17).setVersionType(VersionType.EXTERNAL).execute().actionGet();
assertThat(deleteResponse.isNotFound(), equalTo(true));
assertThat(deleteResponse.isFound(), equalTo(false));
// this should conflict with the delete command transaction which told us that the object was deleted at version 17.
assertThrows(
@ -88,7 +88,7 @@ public class SimpleVersioningTests extends ElasticsearchIntegrationTest {
// Delete with a higher version deletes all versions up to the given one.
DeleteResponse deleteResponse = client().prepareDelete("test", "type", "1").setVersion(17).setVersionType(VersionType.EXTERNAL).execute().actionGet();
assertThat(deleteResponse.isNotFound(), equalTo(false));
assertThat(deleteResponse.isFound(), equalTo(true));
assertThat(deleteResponse.getVersion(), equalTo(17l));
// Deleting with a lower version keeps on failing after a delete.
@ -99,7 +99,7 @@ public class SimpleVersioningTests extends ElasticsearchIntegrationTest {
// But delete with a higher version is OK.
deleteResponse = client().prepareDelete("test", "type", "1").setVersion(18).setVersionType(VersionType.EXTERNAL).execute().actionGet();
assertThat(deleteResponse.isNotFound(), equalTo(true));
assertThat(deleteResponse.isFound(), equalTo(false));
assertThat(deleteResponse.getVersion(), equalTo(18l));
@ -109,7 +109,7 @@ public class SimpleVersioningTests extends ElasticsearchIntegrationTest {
deleteResponse = client().prepareDelete("test", "type", "1").setVersion(20).setVersionType(VersionType.EXTERNAL).execute().actionGet();
assertThat(deleteResponse.isNotFound(), equalTo(false));
assertThat(deleteResponse.isFound(), equalTo(true));
assertThat(deleteResponse.getVersion(), equalTo(20l));
// Make sure that the next delete will be GC. Note we do it on the index settings so it will be cleaned up
@ -193,16 +193,16 @@ public class SimpleVersioningTests extends ElasticsearchIntegrationTest {
}
DeleteResponse deleteResponse = client().prepareDelete("test", "type", "1").setVersion(2).execute().actionGet();
assertThat(deleteResponse.isNotFound(), equalTo(false));
assertThat(deleteResponse.isFound(), equalTo(true));
assertThat(deleteResponse.getVersion(), equalTo(3l));
assertThrows(client().prepareDelete("test", "type", "1").setVersion(2).execute(), VersionConflictEngineException.class);
// This is intricate - the object was deleted but a delete transaction was with the right version. We add another one
// and thus the transcation is increased.
// and thus the transaction is increased.
deleteResponse = client().prepareDelete("test", "type", "1").setVersion(3).execute().actionGet();
assertThat(deleteResponse.isNotFound(), equalTo(true));
assertThat(deleteResponse.isFound(), equalTo(false));
assertThat(deleteResponse.getVersion(), equalTo(4l));
}