/_status doc count of index wrong, closes #1615.

This commit is contained in:
Shay Banon 2012-01-16 13:48:31 +02:00
parent 1f5a74a91a
commit bddea09170
3 changed files with 22 additions and 24 deletions

View File

@ -24,49 +24,49 @@ package org.elasticsearch.action.admin.indices.status;
*/
public class DocsStatus {
int numDocs = 0;
int maxDoc = 0;
int deletedDocs = 0;
long numDocs = 0;
long maxDoc = 0;
long deletedDocs = 0;
/**
* The number of docs.
*/
public int numDocs() {
public long numDocs() {
return numDocs;
}
/**
* The number of docs.
*/
public int getNumDocs() {
public long getNumDocs() {
return numDocs();
}
/**
* The max doc.
*/
public int maxDoc() {
public long maxDoc() {
return maxDoc;
}
/**
* The max doc.
*/
public int getMaxDoc() {
public long getMaxDoc() {
return maxDoc();
}
/**
* The number of deleted docs in the index.
*/
public int deletedDocs() {
public long deletedDocs() {
return deletedDocs;
}
/**
* The number of deleted docs in the index.
*/
public int getDeletedDocs() {
public long getDeletedDocs() {
return deletedDocs();
}
}

View File

@ -36,8 +36,6 @@ import static org.elasticsearch.common.unit.ByteSizeValue.readBytesSizeValue;
/**
* Shard instance (actual allocated shard) status.
*
*
*/
public class ShardStatus extends BroadcastShardOperationResponse {
@ -262,9 +260,9 @@ public class ShardStatus extends BroadcastShardOperationResponse {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
out.writeInt(docs.numDocs());
out.writeInt(docs.maxDoc());
out.writeInt(docs.deletedDocs());
out.writeLong(docs.numDocs());
out.writeLong(docs.maxDoc());
out.writeLong(docs.deletedDocs());
}
if (peerRecoveryStatus == null) {
out.writeBoolean(false);
@ -335,9 +333,9 @@ public class ShardStatus extends BroadcastShardOperationResponse {
translogOperations = in.readLong();
if (in.readBoolean()) {
docs = new DocsStatus();
docs.numDocs = in.readInt();
docs.maxDoc = in.readInt();
docs.deletedDocs = in.readInt();
docs.numDocs = in.readLong();
docs.maxDoc = in.readLong();
docs.deletedDocs = in.readLong();
}
if (in.readBoolean()) {
peerRecoveryStatus = new PeerRecoveryStatus(PeerRecoveryStatus.Stage.fromValue(in.readByte()),

View File

@ -104,7 +104,7 @@ public class SimpleNestedTests extends AbstractNodesTests {
// check the numDocs
IndicesStatusResponse statusResponse = client.admin().indices().prepareStatus().execute().actionGet();
assertThat(statusResponse.index("test").docs().numDocs(), equalTo(3));
assertThat(statusResponse.index("test").docs().numDocs(), equalTo(3l));
// check that _all is working on nested docs
searchResponse = client.prepareSearch("test").setQuery(termQuery("_all", "n_value1_1")).execute().actionGet();
@ -147,7 +147,7 @@ public class SimpleNestedTests extends AbstractNodesTests {
client.admin().indices().prepareFlush().setRefresh(true).execute().actionGet();
statusResponse = client.admin().indices().prepareStatus().execute().actionGet();
assertThat(statusResponse.index("test").docs().numDocs(), equalTo(6));
assertThat(statusResponse.index("test").docs().numDocs(), equalTo(6l));
searchResponse = client.prepareSearch("test").setQuery(nestedQuery("nested1",
boolQuery().must(termQuery("nested1.n_field1", "n_value1_1")).must(termQuery("nested1.n_field2", "n_value2_1")))).execute().actionGet();
@ -174,7 +174,7 @@ public class SimpleNestedTests extends AbstractNodesTests {
client.admin().indices().prepareFlush().setRefresh(true).execute().actionGet();
statusResponse = client.admin().indices().prepareStatus().execute().actionGet();
assertThat(statusResponse.index("test").docs().numDocs(), equalTo(3));
assertThat(statusResponse.index("test").docs().numDocs(), equalTo(3l));
searchResponse = client.prepareSearch("test").setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1_1"))).execute().actionGet();
assertThat(Arrays.toString(searchResponse.shardFailures()), searchResponse.failedShards(), equalTo(0));
@ -230,12 +230,12 @@ public class SimpleNestedTests extends AbstractNodesTests {
client.admin().indices().prepareFlush().setRefresh(true).execute().actionGet();
IndicesStatusResponse statusResponse = client.admin().indices().prepareStatus().execute().actionGet();
assertThat(statusResponse.index("test").docs().numDocs(), equalTo(total * 3));
assertThat(statusResponse.index("test").docs().numDocs(), equalTo(total * 3l));
client.prepareDeleteByQuery("test").setQuery(QueryBuilders.idsQuery("type1").ids(Integer.toString(docToDelete))).execute().actionGet();
client.admin().indices().prepareFlush().setRefresh(true).execute().actionGet();
statusResponse = client.admin().indices().prepareStatus().execute().actionGet();
assertThat(statusResponse.index("test").docs().numDocs(), equalTo((total * 3) - 3));
assertThat(statusResponse.index("test").docs().numDocs(), equalTo((total * 3l) - 3));
for (int i = 0; i < total; i++) {
assertThat(client.prepareGet("test", "type1", Integer.toString(i)).execute().actionGet().exists(), equalTo(i != docToDelete));
@ -257,7 +257,7 @@ public class SimpleNestedTests extends AbstractNodesTests {
noChildrenNestedDeleteByQuery(3, 2);
}
private void noChildrenNestedDeleteByQuery(int total, int docToDelete) throws Exception {
private void noChildrenNestedDeleteByQuery(long total, int docToDelete) throws Exception {
client.admin().indices().prepareDelete().execute().actionGet();
client.admin().indices().prepareCreate("test")
@ -324,7 +324,7 @@ public class SimpleNestedTests extends AbstractNodesTests {
// check the numDocs
IndicesStatusResponse statusResponse = client.admin().indices().prepareStatus().execute().actionGet();
assertThat(statusResponse.index("test").docs().numDocs(), equalTo(7));
assertThat(statusResponse.index("test").docs().numDocs(), equalTo(7l));
// do some multi nested queries
SearchResponse searchResponse = client.prepareSearch("test").setQuery(nestedQuery("nested1",