# Handling the case when the database is empty

**URL:** <https://discuss.elastic.co/t/handling-the-case-when-the-database-is-empty/7481>\
**Category:** Elasticsearch\
**Created:** [April 26, 2012, 7:34pm UTC](https://discuss.elastic.co/t/handling-the-case-when-the-database-is-empty/7481 "2012-04-26T19:34:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Renad\_Ahmed](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@Renad\_Ahmed](https://discuss.elastic.co/u/Renad_Ahmed)\
**Post date:** [April 26, 2012, 7:34pm UTC](https://discuss.elastic.co/t/handling-the-case-when-the-database-is-empty/7481/1 "2012-04-26T19:34:02Z")

</div>

Hi all, I'm using elasticsearch for my application, but each time i  
try to search when the database is empty i get this exception

Execution exception  
IllegalStateException occured : Please re-index, not all indexed items  
are available in the database

In {module:elasticsearch-0.4}/app/controllers/elasticsearch/  
ElasticSearchController.java (around line 367)

363:  
// FIXME Currently we ignore the orderBy and order fields  
364:  
query.from((page - 1) \* getPageSize()).size(getPageSize());  
365:  
query.hydrate(true);  
366:

367:  
return query.fetch(); //here is the highlighted error  
368:

369:  
}  
370:

371:  
/\*\*  
372:  
\* Find by id.  
373:  
\*  
This exception has been logged with id 6a721jbki

---

<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, 3:31am UTC](https://discuss.elastic.co/t/handling-the-case-when-the-database-is-empty/7481/2 "2017-07-06T03:31:00Z")

</div>


