java.lang.ArrayIndexOutOfBoundsException: 1 while preparing the index

I have windows 7 32 bit os
Elastic search is running separately
Java Version: 1.7.0_25

I am new to elastic search, I have not made any changes in
elasticsearch.yml file
I have added the mapping using chrome plugin sense

Mapping
gatereader/gate/_mapping
{
"gate" : {
"_id":{
"path":"id"
},
"properties": {
"id" : {"type": "long"},
"name" : {"type": "string"},
"description" : {"type": "string"},
"isActive" : {"type": "boolean"},
"gateReaderEntityList" :
{"type": "object",
"properties": {
"id" : {"type": "long"},
"readerName" : {"type": "string"},
"readerRefName" : {"type": "string"},
"isActive" : {"type": "boolean"},
"readerType" : {"type": "string"}
}
}
}
}
}

JSON String:
{"id":1,"isActive":true,"description":"","name":"gate","gateReaderEntityList":[{"id":1,"isActive":true,"readerRefName":"Reader","readerType":{"readerType":"Exit"},"readerName":"Reader1"},{"id":2,"isActive":true,"readerRefName":"Reader2","readerType":{"readerType":"Exit"},"readerName":"Reader2"},{"id":3,"isActive":true,"readerRefName":"Reader3","readerType":{"readerType":"Exit"},"readerName":"Reader3"},{"id":4,"isActive":true,"readerRefName":"ExReader1","readerType":{"readerType":"Exit"},"readerName":"ExReader1"},{"id":5,"isActive":true,"readerRefName":"ExReader2","readerType":{"readerType":"Exit"},"readerName":"ExReader2"}]}

Java Code:
Settings settings = ImmutableSettings.settingsBuilder().put()
.put("client.transport.ignore_cluster_name", false).build();

    Client client = new 

TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress("localhost", 9300));

        IndexResponse response1 = client.prepareIndex("gatereader", 

"gate", String.valueOf(1))
.setSource(jsonstring).execute().actionGet();

I am getting exception
java.lang.ArrayIndexOutOfBoundsException: 1
at
org.elasticsearch.action.index.IndexRequest.source(IndexRequest.java:419)
at
org.elasticsearch.action.index.IndexRequestBuilder.setSource(IndexRequestBuilder.java:209)
at
waidTenant.ApplicationContextLoader.elasticsearch(ApplicationContextLoader.java:230)
at
waidTenant.ApplicationContextLoader.main(ApplicationContextLoader.java:164)

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

The number of arguments that you are passing to:

at 

org.elasticsearch.action.index.IndexRequestBuilder.setSource(IndexRequestBuilder.java:209)

must be even, I guess it's an odd number? Can you tell what args you are
passing to it?

simon
On Thursday, October 10, 2013 9:43:34 AM UTC+2, kiran wrote:

I have windows 7 32 bit os
Elastic search is running separately
Java Version: 1.7.0_25

I am new to Elasticsearch, I have not made any changes in
elasticsearch.yml file
I have added the mapping using chrome plugin sense

Mapping
gatereader/gate/_mapping
{
"gate" : {
"_id":{
"path":"id"
},
"properties": {
"id" : {"type": "long"},
"name" : {"type": "string"},
"description" : {"type": "string"},
"isActive" : {"type": "boolean"},
"gateReaderEntityList" :
{"type": "object",
"properties": {
"id" : {"type": "long"},
"readerName" : {"type": "string"},
"readerRefName" : {"type": "string"},
"isActive" : {"type": "boolean"},
"readerType" : {"type": "string"}
}
}
}
}
}

JSON String:

{"id":1,"isActive":true,"description":"","name":"gate","gateReaderEntityList":[{"id":1,"isActive":true,"readerRefName":"Reader","readerType":{"readerType":"Exit"},"readerName":"Reader1"},{"id":2,"isActive":true,"readerRefName":"Reader2","readerType":{"readerType":"Exit"},"readerName":"Reader2"},{"id":3,"isActive":true,"readerRefName":"Reader3","readerType":{"readerType":"Exit"},"readerName":"Reader3"},{"id":4,"isActive":true,"readerRefName":"ExReader1","readerType":{"readerType":"Exit"},"readerName":"ExReader1"},{"id":5,"isActive":true,"readerRefName":"ExReader2","readerType":{"readerType":"Exit"},"readerName":"ExReader2"}]}

Java Code:
Settings settings = ImmutableSettings.settingsBuilder().put()
.put("client.transport.ignore_cluster_name",
false).build();

    Client client = new 

TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress("localhost", 9300));

        IndexResponse response1 = client.prepareIndex("gatereader", 

"gate", String.valueOf(1))
.setSource(jsonstring).execute().actionGet();

I am getting exception
java.lang.ArrayIndexOutOfBoundsException: 1
at
org.elasticsearch.action.index.IndexRequest.source(IndexRequest.java:419)
at
org.elasticsearch.action.index.IndexRequestBuilder.setSource(IndexRequestBuilder.java:209)
at
waidTenant.ApplicationContextLoader.elasticsearch(ApplicationContextLoader.java:230)
at
waidTenant.ApplicationContextLoader.main(ApplicationContextLoader.java:164)

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

IndexResponse response1 = client.prepareIndex("gatereader", "gate",
String.valueOf(gateEntry.getKey()))
.setSource(new JSONObject("").execute().actionGet();

On Thursday, October 10, 2013 1:57:51 PM UTC+5:30, simonw wrote:

The number of arguments that you are passing to:

at 

org.elasticsearch.action.index.IndexRequestBuilder.setSource(IndexRequestBuilder.java:209)

must be even, I guess it's an odd number? Can you tell what args you are
passing to it?

simon
On Thursday, October 10, 2013 9:43:34 AM UTC+2, kiran wrote:

I have windows 7 32 bit os
Elastic search is running separately
Java Version: 1.7.0_25

I am new to Elasticsearch, I have not made any changes in
elasticsearch.yml file
I have added the mapping using chrome plugin sense

Mapping
gatereader/gate/_mapping
{
"gate" : {
"_id":{
"path":"id"
},
"properties": {
"id" : {"type": "long"},
"name" : {"type": "string"},
"description" : {"type": "string"},
"isActive" : {"type": "boolean"},
"gateReaderEntityList" :
{"type": "object",
"properties": {
"id" : {"type": "long"},
"readerName" : {"type": "string"},
"readerRefName" : {"type": "string"},
"isActive" : {"type": "boolean"},
"readerType" : {"type": "string"}
}
}
}
}
}

JSON String:

{"id":1,"isActive":true,"description":"","name":"gate","gateReaderEntityList":[{"id":1,"isActive":true,"readerRefName":"Reader","readerType":{"readerType":"Exit"},"readerName":"Reader1"},{"id":2,"isActive":true,"readerRefName":"Reader2","readerType":{"readerType":"Exit"},"readerName":"Reader2"},{"id":3,"isActive":true,"readerRefName":"Reader3","readerType":{"readerType":"Exit"},"readerName":"Reader3"},{"id":4,"isActive":true,"readerRefName":"ExReader1","readerType":{"readerType":"Exit"},"readerName":"ExReader1"},{"id":5,"isActive":true,"readerRefName":"ExReader2","readerType":{"readerType":"Exit"},"readerName":"ExReader2"}]}

Java Code:
Settings settings = ImmutableSettings.settingsBuilder().put()
.put("client.transport.ignore_cluster_name",
false).build();

    Client client = new 

TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress("localhost", 9300));

        IndexResponse response1 = client.prepareIndex("gatereader", 

"gate", String.valueOf(1))
.setSource(jsonstring).execute().actionGet();

I am getting exception
java.lang.ArrayIndexOutOfBoundsException: 1
at
org.elasticsearch.action.index.IndexRequest.source(IndexRequest.java:419)
at
org.elasticsearch.action.index.IndexRequestBuilder.setSource(IndexRequestBuilder.java:209)
at
waidTenant.ApplicationContextLoader.elasticsearch(ApplicationContextLoader.java:230)
at
waidTenant.ApplicationContextLoader.main(ApplicationContextLoader.java:164)

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks for the reply,
I got it working, earlier I was adding the JSON object directly to the
source now i changed to json string.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

I just pushed a better error message for this:

simon

On Thursday, October 10, 2013 10:49:04 AM UTC+2, kiran wrote:

Thanks for the reply,
I got it working, earlier I was adding the JSON object directly to the
source now i changed to json string.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.