/_status doc count of index wrong, closes #1615.
This commit is contained in:
parent
1f5a74a91a
commit
bddea09170
|
@ -24,49 +24,49 @@ package org.elasticsearch.action.admin.indices.status;
|
||||||
*/
|
*/
|
||||||
public class DocsStatus {
|
public class DocsStatus {
|
||||||
|
|
||||||
int numDocs = 0;
|
long numDocs = 0;
|
||||||
int maxDoc = 0;
|
long maxDoc = 0;
|
||||||
int deletedDocs = 0;
|
long deletedDocs = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of docs.
|
* The number of docs.
|
||||||
*/
|
*/
|
||||||
public int numDocs() {
|
public long numDocs() {
|
||||||
return numDocs;
|
return numDocs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of docs.
|
* The number of docs.
|
||||||
*/
|
*/
|
||||||
public int getNumDocs() {
|
public long getNumDocs() {
|
||||||
return numDocs();
|
return numDocs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The max doc.
|
* The max doc.
|
||||||
*/
|
*/
|
||||||
public int maxDoc() {
|
public long maxDoc() {
|
||||||
return maxDoc;
|
return maxDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The max doc.
|
* The max doc.
|
||||||
*/
|
*/
|
||||||
public int getMaxDoc() {
|
public long getMaxDoc() {
|
||||||
return maxDoc();
|
return maxDoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of deleted docs in the index.
|
* The number of deleted docs in the index.
|
||||||
*/
|
*/
|
||||||
public int deletedDocs() {
|
public long deletedDocs() {
|
||||||
return deletedDocs;
|
return deletedDocs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of deleted docs in the index.
|
* The number of deleted docs in the index.
|
||||||
*/
|
*/
|
||||||
public int getDeletedDocs() {
|
public long getDeletedDocs() {
|
||||||
return deletedDocs();
|
return deletedDocs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,6 @@ import static org.elasticsearch.common.unit.ByteSizeValue.readBytesSizeValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shard instance (actual allocated shard) status.
|
* Shard instance (actual allocated shard) status.
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ShardStatus extends BroadcastShardOperationResponse {
|
public class ShardStatus extends BroadcastShardOperationResponse {
|
||||||
|
|
||||||
|
@ -262,9 +260,9 @@ public class ShardStatus extends BroadcastShardOperationResponse {
|
||||||
out.writeBoolean(false);
|
out.writeBoolean(false);
|
||||||
} else {
|
} else {
|
||||||
out.writeBoolean(true);
|
out.writeBoolean(true);
|
||||||
out.writeInt(docs.numDocs());
|
out.writeLong(docs.numDocs());
|
||||||
out.writeInt(docs.maxDoc());
|
out.writeLong(docs.maxDoc());
|
||||||
out.writeInt(docs.deletedDocs());
|
out.writeLong(docs.deletedDocs());
|
||||||
}
|
}
|
||||||
if (peerRecoveryStatus == null) {
|
if (peerRecoveryStatus == null) {
|
||||||
out.writeBoolean(false);
|
out.writeBoolean(false);
|
||||||
|
@ -335,9 +333,9 @@ public class ShardStatus extends BroadcastShardOperationResponse {
|
||||||
translogOperations = in.readLong();
|
translogOperations = in.readLong();
|
||||||
if (in.readBoolean()) {
|
if (in.readBoolean()) {
|
||||||
docs = new DocsStatus();
|
docs = new DocsStatus();
|
||||||
docs.numDocs = in.readInt();
|
docs.numDocs = in.readLong();
|
||||||
docs.maxDoc = in.readInt();
|
docs.maxDoc = in.readLong();
|
||||||
docs.deletedDocs = in.readInt();
|
docs.deletedDocs = in.readLong();
|
||||||
}
|
}
|
||||||
if (in.readBoolean()) {
|
if (in.readBoolean()) {
|
||||||
peerRecoveryStatus = new PeerRecoveryStatus(PeerRecoveryStatus.Stage.fromValue(in.readByte()),
|
peerRecoveryStatus = new PeerRecoveryStatus(PeerRecoveryStatus.Stage.fromValue(in.readByte()),
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class SimpleNestedTests extends AbstractNodesTests {
|
||||||
|
|
||||||
// check the numDocs
|
// check the numDocs
|
||||||
IndicesStatusResponse statusResponse = client.admin().indices().prepareStatus().execute().actionGet();
|
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
|
// check that _all is working on nested docs
|
||||||
searchResponse = client.prepareSearch("test").setQuery(termQuery("_all", "n_value1_1")).execute().actionGet();
|
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();
|
client.admin().indices().prepareFlush().setRefresh(true).execute().actionGet();
|
||||||
|
|
||||||
statusResponse = client.admin().indices().prepareStatus().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",
|
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();
|
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();
|
client.admin().indices().prepareFlush().setRefresh(true).execute().actionGet();
|
||||||
|
|
||||||
statusResponse = client.admin().indices().prepareStatus().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();
|
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));
|
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();
|
client.admin().indices().prepareFlush().setRefresh(true).execute().actionGet();
|
||||||
IndicesStatusResponse statusResponse = client.admin().indices().prepareStatus().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.prepareDeleteByQuery("test").setQuery(QueryBuilders.idsQuery("type1").ids(Integer.toString(docToDelete))).execute().actionGet();
|
||||||
client.admin().indices().prepareFlush().setRefresh(true).execute().actionGet();
|
client.admin().indices().prepareFlush().setRefresh(true).execute().actionGet();
|
||||||
statusResponse = client.admin().indices().prepareStatus().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++) {
|
for (int i = 0; i < total; i++) {
|
||||||
assertThat(client.prepareGet("test", "type1", Integer.toString(i)).execute().actionGet().exists(), equalTo(i != docToDelete));
|
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);
|
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().prepareDelete().execute().actionGet();
|
||||||
|
|
||||||
client.admin().indices().prepareCreate("test")
|
client.admin().indices().prepareCreate("test")
|
||||||
|
@ -324,7 +324,7 @@ public class SimpleNestedTests extends AbstractNodesTests {
|
||||||
|
|
||||||
// check the numDocs
|
// check the numDocs
|
||||||
IndicesStatusResponse statusResponse = client.admin().indices().prepareStatus().execute().actionGet();
|
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
|
// do some multi nested queries
|
||||||
SearchResponse searchResponse = client.prepareSearch("test").setQuery(nestedQuery("nested1",
|
SearchResponse searchResponse = client.prepareSearch("test").setQuery(nestedQuery("nested1",
|
||||||
|
|
Loading…
Reference in New Issue