Java API - strange behavior on first time index creation

Hi,
Tried to create index on clean elasticsearch 0.16.1 and got exception:

The code :
IndexResponse indexRes = client.prepareIndex("test", "contacts",
"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test")
.field("BirthDate", new Date())
.field("Email", "test@test.com")
.endObject()
).execute()
.actionGet();

Exception in thread "main"
org.elasticsearch.indices.IndexMissingException: [test] missing
at
org.elasticsearch.cluster.metadata.MetaData.concreteIndex(MetaData.java:
211)
at
org.elasticsearch.action.index.TransportIndexAction.innerExecute(TransportIndexAction.java:
123)
at org.elasticsearch.action.index.TransportIndexAction.access
$000(TransportIndexAction.java:70)
at org.elasticsearch.action.index.TransportIndexAction
$1.onResponse(TransportIndexAction.java:104)
at org.elasticsearch.action.index.TransportIndexAction
$1.onResponse(TransportIndexAction.java:102)
at org.elasticsearch.action.support.BaseAction$ThreadedActionListener
$1.run(BaseAction.java:84)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Next run of the same code - works fine.

Another issue that I can't exactly isolate the behavior is I have code
that creates indexes with long and complex index name and id = 1
then after index is created , the search across _all doesn't return
any hits. Same code, with id = null works file and search returns
hits.

Same code with simple index name :
IndexResponse indexRes = client.prepareIndex("test", "contacts",
"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test")
.field("BirthDate", new Date())
.field("Email", "test@test.com")
.endObject()
).execute()
.actionGet();

even with id = 1 makes next search positive. I really tried to find
what I'm doing wrong, but same code, differences only index name and
id.

Clean installation of elasticsearch.

Thank You and Best Regards/

I just started looking at Elasticsearch today and noticed that index
updates in general do not seem to save right away. I guess it is the
nature of being distributed?

	IndexRequestBuilder builder = client.prepareIndex("test", "asset",

"103");
IndexResponse response =
builder.setSource(XContentFactory.jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", new Date())
.field("message", "trying out Elastic Search")
.endObject()
)
.execute().actionGet();

	SearchResponse results = client.prepareSearch("test")
	        .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
	        .setQuery(QueryBuilders.termQuery("user", "kimchy"))
	        .setFrom(0).setSize(60).setExplain(true)
	        .execute()
	        .actionGet();

	log("Found " + results.getHits().totalHits() );

This main method will find 0 results. Next time I run it it will find
1

On May 30, 6:12 pm, slavag slav...@gmail.com wrote:

Hi,
Tried to create index on clean elasticsearch 0.16.1 and got exception:

The code :
IndexResponse indexRes = client.prepareIndex("test", "contacts",
"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test")
.field("BirthDate", new Date())
.field("Email", "t...@test.com")
.endObject()
).execute()
.actionGet();

Exception in thread "main"
org.elasticsearch.indices.IndexMissingException: [test] missing
at
org.elasticsearch.cluster.metadata.MetaData.concreteIndex(MetaData.java:
211)
at
org.elasticsearch.action.index.TransportIndexAction.innerExecute(TransportIndexAction.java:
123)
at org.elasticsearch.action.index.TransportIndexAction.access
$000(TransportIndexAction.java:70)
at org.elasticsearch.action.index.TransportIndexAction
$1.onResponse(TransportIndexAction.java:104)
at org.elasticsearch.action.index.TransportIndexAction
$1.onResponse(TransportIndexAction.java:102)
at org.elasticsearch.action.support.BaseAction$ThreadedActionListener
$1.run(BaseAction.java:84)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Next run of the same code - works fine.

Another issue that I can't exactly isolate the behavior is I have code
that creates indexes with long and complex index name and id = 1
then after index is created , the search across _all doesn't return
any hits. Same code, with id = null works file and search returns
hits.

Same code with simple index name :
IndexResponse indexRes = client.prepareIndex("test", "contacts",
"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test")
.field("BirthDate", new Date())
.field("Email", "t...@test.com")
.endObject()
).execute()
.actionGet();

even with id = 1 makes next search positive. I really tried to find
what I'm doing wrong, but same code, differences only index name and
id.

Clean installation of elasticsearch.

Thank You and Best Regards/

The document is saved, but not immediately avail. for search. If you need
to save it and then search on it immediately, try calling the _refresh
method after the save.

On Tue, May 31, 2011 at 7:12 PM, Christopher Burkey <
christopher.burkey@gmail.com> wrote:

I just started looking at Elasticsearch today and noticed that index
updates in general do not seem to save right away. I guess it is the
nature of being distributed?

           IndexRequestBuilder builder = client.prepareIndex("test",

"asset",
"103");
IndexResponse response =
builder.setSource(XContentFactory.jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", new Date())
.field("message", "trying out Elastic Search")
.endObject()
)
.execute().actionGet();

           SearchResponse results = client.prepareSearch("test")
                   .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
                   .setQuery(QueryBuilders.termQuery("user", "kimchy"))
                   .setFrom(0).setSize(60).setExplain(true)
                   .execute()
                   .actionGet();

           log("Found " + results.getHits().totalHits() );

This main method will find 0 results. Next time I run it it will find
1

On May 30, 6:12 pm, slavag slav...@gmail.com wrote:

Hi,
Tried to create index on clean elasticsearch 0.16.1 and got exception:

The code :
IndexResponse indexRes =
client.prepareIndex("test", "contacts",
"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test")
.field("BirthDate", new Date())
.field("Email", "t...@test.com")
.endObject()
).execute()
.actionGet();

Exception in thread "main"
org.elasticsearch.indices.IndexMissingException: [test] missing
at
org.elasticsearch.cluster.metadata.MetaData.concreteIndex(MetaData.java:
211)
at

org.elasticsearch.action.index.TransportIndexAction.innerExecute(TransportIndexAction.java:

  1. at org.elasticsearch.action.index.TransportIndexAction.access
    $000(TransportIndexAction.java:70)
    at org.elasticsearch.action.index.TransportIndexAction
    $1.onResponse(TransportIndexAction.java:104)
    at org.elasticsearch.action.index.TransportIndexAction
    $1.onResponse(TransportIndexAction.java:102)
    at
    org.elasticsearch.action.support.BaseAction$ThreadedActionListener
    $1.run(BaseAction.java:84)
    at java.util.concurrent.ThreadPoolExecutor
    $Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor
    $Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

Next run of the same code - works fine.

Another issue that I can't exactly isolate the behavior is I have code
that creates indexes with long and complex index name and id = 1
then after index is created , the search across _all doesn't return
any hits. Same code, with id = null works file and search returns
hits.

Same code with simple index name :
IndexResponse indexRes =
client.prepareIndex("test", "contacts",
"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test")
.field("BirthDate", new Date())
.field("Email", "t...@test.com")
.endObject()
).execute()
.actionGet();

even with id = 1 makes next search positive. I really tried to find
what I'm doing wrong, but same code, differences only index name and
id.

Clean installation of elasticsearch.

Thank You and Best Regards/

Another option is to set the refresh flag when indexing. But, a note here, this is handy when writing tests and the like (calling refresh API, or setting the refresh flag), but should not be used in production. Refresh comes with an overhead, and refresh should be done using the automatic async refreshing process.

On Wednesday, June 1, 2011 at 4:23 AM, Dan Young wrote:

The document is saved, but not immediately avail. for search. If you need to save it and then search on it immediately, try calling the _refresh method after the save.

Elasticsearch Platform — Find real-time answers at scale | Elastic

On Tue, May 31, 2011 at 7:12 PM, Christopher Burkey <christopher.burkey@gmail.com (mailto:christopher.burkey@gmail.com)> wrote:

I just started looking at Elasticsearch today and noticed that index
updates in general do not seem to save right away. I guess it is the
nature of being distributed?

IndexRequestBuilder builder = client.prepareIndex("test", "asset",
"103");
IndexResponse response =
builder.setSource(XContentFactory.jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", new Date())
.field("message", "trying out Elastic Search")
.endObject()
)
.execute().actionGet();

SearchResponse results = client.prepareSearch("test")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(QueryBuilders.termQuery("user", "kimchy"))
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();

log("Found " + results.getHits().totalHits() );

This main method will find 0 results. Next time I run it it will find
1

On May 30, 6:12 pm, slavag <slav...@gmail.com (mailto:slav...@gmail.com)> wrote:

Hi,
Tried to create index on clean elasticsearch 0.16.1 and got exception:

The code :
IndexResponse indexRes = client.prepareIndex("test", "contacts",
"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test")
.field("BirthDate", new Date())
.field("Email", "t...@test.com (mailto:t...@test.com)")
.endObject()
).execute()
.actionGet();

Exception in thread "main"
org.elasticsearch.indices.IndexMissingException: [test] missing
at
org.elasticsearch.cluster.metadata.MetaData.concreteIndex(MetaData.java:
211)
at
org.elasticsearch.action.index.TransportIndexAction.innerExecute(TransportIndexAction.java:
123)
at org.elasticsearch.action.index.TransportIndexAction.access
$000(TransportIndexAction.java:70)
at org.elasticsearch.action.index.TransportIndexAction
$1.onResponse(TransportIndexAction.java:104)
at org.elasticsearch.action.index.TransportIndexAction
$1.onResponse(TransportIndexAction.java:102)
at org.elasticsearch.action.support.BaseAction$ThreadedActionListener
$1.run(BaseAction.java:84)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Next run of the same code - works fine.

Another issue that I can't exactly isolate the behavior is I have code
that creates indexes with long and complex index name and id = 1
then after index is created , the search across _all doesn't return
any hits. Same code, with id = null works file and search returns
hits.

Same code with simple index name :
IndexResponse indexRes = client.prepareIndex("test", "contacts",
"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test")
.field("BirthDate", new Date())
.field("Email", "t...@test.com (mailto:t...@test.com)")
.endObject()
).execute()
.actionGet();

even with id = 1 makes next search positive. I really tried to find
what I'm doing wrong, but same code, differences only index name and
id.

Clean installation of elasticsearch.

Thank You and Best Regards/

Hi,
I tried to search 5 min after I tried to index the data , on the clean
Elasticsearch installed on the same computer where my process is
running.
Should it take more then 5 min is such situation ?

What about first index exception ?

Best Regards.

On Jun 1, 5:09 am, Shay Banon shay.ba...@elasticsearch.com wrote:

Another option is to set the refresh flag when indexing. But, a note here, this is handy when writing tests and the like (calling refresh API, or setting the refresh flag), but should not be used in production. Refresh comes with an overhead, and refresh should be done using the automatic async refreshing process.

On Wednesday, June 1, 2011 at 4:23 AM, Dan Young wrote:

The document is saved, but not immediately avail. for search. If you need to save it and then search on it immediately, try calling the _refresh method after the save.

Elasticsearch Platform — Find real-time answers at scale | Elastic...

On Tue, May 31, 2011 at 7:12 PM, Christopher Burkey <christopher.bur...@gmail.com (mailto:christopher.bur...@gmail.com)> wrote:

I just started looking at Elasticsearch today and noticed that index
updates in general do not seem to save right away. I guess it is the
nature of being distributed?

IndexRequestBuilder builder = client.prepareIndex("test", "asset",
"103");
IndexResponse response =
builder.setSource(XContentFactory.jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", new Date())
.field("message", "trying out Elastic Search")
.endObject()
)
.execute().actionGet();

SearchResponse results = client.prepareSearch("test")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(QueryBuilders.termQuery("user", "kimchy"))
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();

log("Found " + results.getHits().totalHits() );

This main method will find 0 results. Next time I run it it will find
1

On May 30, 6:12 pm, slavag <slav...@gmail.com (mailto:slav...@gmail.com)> wrote:

Hi,
Tried to create index on clean elasticsearch 0.16.1 and got exception:

The code :
IndexResponse indexRes = client.prepareIndex("test", "contacts",
"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test")
.field("BirthDate", new Date())
.field("Email", "t...@test.com (mailto:t...@test.com)")
.endObject()
).execute()
.actionGet();

Exception in thread "main"
org.elasticsearch.indices.IndexMissingException: [test] missing
at
org.elasticsearch.cluster.metadata.MetaData.concreteIndex(MetaData.java:
211)
at
org.elasticsearch.action.index.TransportIndexAction.innerExecute(TransportI ndexAction.java:
123)
at org.elasticsearch.action.index.TransportIndexAction.access
$000(TransportIndexAction.java:70)
at org.elasticsearch.action.index.TransportIndexAction
$1.onResponse(TransportIndexAction.java:104)
at org.elasticsearch.action.index.TransportIndexAction
$1.onResponse(TransportIndexAction.java:102)
at org.elasticsearch.action.support.BaseAction$ThreadedActionListener
$1.run(BaseAction.java:84)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

Next run of the same code - works fine.

Another issue that I can't exactly isolate the behavior is I have code
that creates indexes with long and complex index name and id = 1
then after index is created , the search across _all doesn't return
any hits. Same code, with id = null works file and search returns
hits.

Same code with simple index name :
IndexResponse indexRes = client.prepareIndex("test", "contacts",
"1")
.setSource(jsonBuilder()
.startObject()
.field("Name", "Test")
.field("BirthDate", new Date())
.field("Email", "t...@test.com (mailto:t...@test.com)")
.endObject()
).execute()
.actionGet();

even with id = 1 makes next search positive. I really tried to find
what I'm doing wrong, but same code, differences only index name and
id.

Clean installation of elasticsearch.

Thank You and Best Regards/