# Outdated information using Java client TermVector and COUNT api

**URL:** https://discuss.elastic.co/t/outdated-information-using-java-client-termvector-and-count-api/831
**Category:** Elasticsearch
**Created:** [May 18, 2015, 10:07am UTC](https://discuss.elastic.co/t/outdated-information-using-java-client-termvector-and-count-api/831 "2015-05-18T10:07:18Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kush](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@kush](https://discuss.elastic.co/u/kush)
#### Post date: [May 18, 2015, 10:07am UTC](https://discuss.elastic.co/t/outdated-information-using-java-client-termvector-and-count-api/831/1 "2015-05-18T10:07:18Z")

</div>

Hi,

I have a requirement to perform a computation using the total document count and term vector statistics of the document terms.  
For this i am using

1. The COUNT API ([https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/count.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/count.html)) for getting the total number of documents in the elastic search type of the elastic search index.
2. The Term vector API ([https://www.elastic.co/guide/en/elasticsearch/reference/1.4/docs-termvectors.html](https://www.elastic.co/guide/en/elasticsearch/reference/1.4/docs-termvectors.html)) to get the document frequency.  
I am using Java client API to access the elastic search server.

I index a document using the java api and use IndexResponse.isCreated() to ascertain that the indexing of the document is completed.  
But i am getting outdated/old count and term vector information, if i try to retrieve document count,termvector immediately after indexing the document.

Whereas if i wait for 30 seconds,i get the latest document count and term vector information.

I have created a single index on a single node with a single shard using the following command.  
curl -XPUT '127.0.0.1:9200/test' -d '  
{  
"settings":{  
"analysis": {  
"analyzer": {  
"myAnalyzer1":{  
"type": "custom",  
"tokenizer" : "PatternAnalyzer"  
}  
},  
"tokenizer" :{  
"PatternAnalyzer": {  
"type": "pattern",  
"pattern": "patternvalue"  
}  
}  
},  
"index" : {  
"number\_of\_shards" : 1,  
"number\_of\_replicas" : 0  
}  
}  
}'

State of the cluster is shared below.  
{  
"cluster\_name": "elasticsearch",  
"status": "yellow",  
"timed\_out": false,  
"number\_of\_nodes": 1,  
"number\_of\_data\_nodes": 1,  
"active\_primary\_shards": 30,  
"active\_shards": 30,  
"relocating\_shards": 0,  
"initializing\_shards": 0,  
"unassigned\_shards": 15,  
"number\_of\_pending\_tasks": 0  
}

Is this expected behavior? If yes, Pls suggest a strategy to get the latest term vector information accurately.

Regards,  
Kush

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 12:13am UTC](https://discuss.elastic.co/t/outdated-information-using-java-client-termvector-and-count-api/831/2 "2017-07-06T00:13:34Z")

</div>


