It's valid in term of JS not for Elasticsearch.
I mean that Elasticsearch needs to create a mapping for each field.

Your field user can not be at the same time a number and an object.
You can write this (pseudo JSON):

User : {
  age : 10,
  Name: Joe 
}


Or this:

User : [{
  age : 10,
  Name: Joe 
},{
  age : 12,
  Name: John  
}]


HTH
--
David ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

> Le 6 févr. 2015 à 01:26, Vicente de Rivera III <[email protected]> a 
> écrit :
> 
> Thank you for the response.
> 
> Both jsonlint.com and http://codebeautify.org/jsonvalidate says this JSON is 
> valid:
> 
> {
>     "x": {
>         "user": [
>             0,
>             {
>                 "x": 1
>             }
>         ]
>     }
> }
> 
> 
> I guess I'll parse that raw js data, build POJOs out of it and then pass 
> these pojos into ES. (Was hoping I could dump this data into elastic search 
> without any trouble).
> 
> Also, sorry to ask this, is Elastic search a good choice for my goals? I've 
> never used any search technology before.
> 
> 
>> On Friday, February 6, 2015 at 6:02:40 AM UTC+8, David Pilato wrote:
>> Unsure but your JSON looks incorrect to me. You are trying to send in an 
>> array a number 0 and an object. 
>> 
>> 
>> David
>> 
>>> Le 5 févr. 2015 à 22:53, Vicente de Rivera III <[email protected]> a 
>>> écrit :
>>> 
>>> Code to reproduce the exception:
>>> 
>>>     @Test
>>>     public void testESIndex() throws Exception {
>>>             String json = "{" +  
>>>                              "\"user\":[0, {\"x\":1}]" + 
>>>                           "}";
>>>             Client client = new TransportClient()
>>>             .addTransportAddress(new InetSocketTransportAddress(
>>>                             "localhost", 9300));
>>>             
>>>             IndexResponse indexResponse = index(client, "a", "y", "{\"x\":" 
>>> + json + "}");
>>>             
>>>             logger.info(indexResponseToString(indexResponse));
>>>             
>>>             client.close();
>>>     }
>>>     
>>>     public static IndexResponse index(Client client, String index, String 
>>> type, String json) {
>>>             IndexResponse actionGet = client.prepareIndex(index, type)
>>>                             .setSource(json).execute().actionGet();
>>>             return actionGet;
>>>     }
>>>     
>>> 
>>>     public static String indexResponseToString(IndexResponse actionGet) {
>>>             return actionGet.getIndex() + "/" + actionGet.getType() + "/"
>>>                             + actionGet.getId() + " isCreated: " + 
>>> actionGet.isCreated();
>>>     }
>>> 
>>> 
>>> 
>>> -- 
>>> 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 [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/elasticsearch/1b558488-1064-4056-b666-25e6226fdd66%40googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/elasticsearch/9358cf2e-c72e-4455-9b45-e7b443a124db%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/0AA64161-1385-4DDE-957B-8D7B63495A8D%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

Reply via email to