# Creating and opening index for file-based embedded index?

**URL:** <https://discuss.elastic.co/t/creating-and-opening-index-for-file-based-embedded-index/14430>\
**Category:** Elasticsearch\
**Created:** [November 15, 2013, 4:07pm UTC](https://discuss.elastic.co/t/creating-and-opening-index-for-file-based-embedded-index/14430 "2013-11-15T16:07:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackpark](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jackpark](https://discuss.elastic.co/u/jackpark)\
**Post date:** [November 15, 2013, 4:07pm UTC](https://discuss.elastic.co/t/creating-and-opening-index-for-file-based-embedded-index/14430/1 "2013-11-15T16:07:23Z")

</div>

Are there specific procedures for creating an index to be used when running  
an embedded file-based client?  
My question arises out of unit tests on a simple client created as shown at  
the ES client page. It will successfully index a document, then immediately  
read it back. But, when I open that client again to read it later, that  
index is null.

When I create a node, to get the client and give it a data path, etc, then  
use the client on a named index, I'm guessing that doesn't create the named  
index, even though I see data in folders.

What am I missing?  
Many thanks in advance.  
Jack

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jackpark](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jackpark](https://discuss.elastic.co/u/jackpark)\
**Post date:** [November 15, 2013, 6:47pm UTC](https://discuss.elastic.co/t/creating-and-opening-index-for-file-based-embedded-index/14430/2 "2013-11-15T18:47:58Z")

</div>

An update:  
I found some code which tests for existence of an index and creates it if  
it is not there.  
I now see this message:

NoShardAvailableActionException: [testindex][0] null

even though the index is there and it is not locked.

Testing works this way:

One unit test creates a document then reads it back then closes the node  
and client.  
Second unit test simply goes back and reads the document, resulting in that  
error.

But, if I run in debug mode (Eclipse), and walk the second unit test  
through, it reads the document with no errors.

My reading routing allows for 10 seconds in its get() as follows:

GetResponse resp = client.prepareGet(idx, typ, documentId).get("10000");

Confusing why walking through the code slowly allows success, but running  
directly does not.

On Friday, November 15, 2013 8:07:23 AM UTC-8, [jack...@topicquests.org](mailto:jack...@topicquests.org)  
wrote:

> Are there specific procedures for creating an index to be used when  
> running an embedded file-based client?  
> My question arises out of unit tests on a simple client created as shown  
> at the ES client page. It will successfully index a document, then  
> immediately read it back. But, when I open that client again to read it  
> later, that index is null.
> 
> When I create a node, to get the client and give it a data path, etc, then  
> use the client on a named index, I'm guessing that doesn't create the named  
> index, even though I see data in folders.
> 
> What am I missing?  
> Many thanks in advance.  
> Jack

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jackpark](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jackpark](https://discuss.elastic.co/u/jackpark)\
**Post date:** [November 15, 2013, 7:36pm UTC](https://discuss.elastic.co/t/creating-and-opening-index-for-file-based-embedded-index/14430/3 "2013-11-15T19:36:36Z")

</div>

A fix was discovered in a message by David Pilato earlier with a link to  
this:

> <https://github.com/elasticsearchfr/hands-on/blob/answers/src/test/java/org/elasticsearchfr/handson/StartNode.java#L32>

which appears to have resolved my issues.

The context of my query is specifically that of a local, embedded Client  
using a file-based index.

Answer to my opening question appears to be simply this: look to see if  
your indexes are created by following APIs in AdminClient; if not, create  
them. But, before you do that, create the node, then client, then use that  
test suggested above to wait for the Client to settle.

On Friday, November 15, 2013 10:47:58 AM UTC-8, [jack...@topicquests.org](mailto:jack...@topicquests.org)  
wrote:

> An update:  
> I found some code which tests for existence of an index and creates it if  
> it is not there.  
> I now see this message:
> 
> NoShardAvailableActionException: [testindex][0] null
> 
> even though the index is there and it is not locked.
> 
> Testing works this way:
> 
> One unit test creates a document then reads it back then closes the node  
> and client.  
> Second unit test simply goes back and reads the document, resulting in  
> that error.
> 
> But, if I run in debug mode (Eclipse), and walk the second unit test  
> through, it reads the document with no errors.
> 
> My reading routing allows for 10 seconds in its get() as follows:
> 
> GetResponse resp = client.prepareGet(idx, typ, documentId).get("10000");
> 
> Confusing why walking through the code slowly allows success, but running  
> directly does not.
> 
> On Friday, November 15, 2013 8:07:23 AM UTC-8, jack...@topicquests.orgwrote:
> 
> > Are there specific procedures for creating an index to be used when  
> > running an embedded file-based client?  
> > My question arises out of unit tests on a simple client created as shown  
> > at the ES client page. It will successfully index a document, then  
> > immediately read it back. But, when I open that client again to read it  
> > later, that index is null.
> > 
> > When I create a node, to get the client and give it a data path, etc,  
> > then use the client on a named index, I'm guessing that doesn't create the  
> > named index, even though I see data in folders.
> > 
> > What am I missing?  
> > Many thanks in advance.  
> > Jack

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:06am UTC](https://discuss.elastic.co/t/creating-and-opening-index-for-file-based-embedded-index/14430/4 "2017-07-06T02:06:41Z")

</div>


