This was quite helpful.

I do have one question though. Is elasticSearchMappings of type Settings?

Ethan

On Thursday, January 12, 2012 8:09:01 PM UTC-5, Lorrin Nelson wrote:
>
> Hi David, 
>
> That helped, thanks. After getting the builder stuff working following 
> the example, I switched over to supplying the settings as a JSON 
> string with the following command: 
>             CreateIndexResponse createIndexResponse = 
> client.admin().indices() 
>                     .prepareCreate(indexName) 
>                     .setSettings(elasticSearchSettings) 
>                     .addMapping(elasticSearchType, 
> elasticSearchMappings) 
>                     .execute().actionGet(); 
>
> where elasticSearchSettings is: 
> { 
>     "index" : { 
>         "number_of_shards" : 2, 
>         "number_of_replicas" : 1 
>     } 
> } 
>
> and elasticSearchMappings is in the format 
> { 
>     "<elasticSearchType>" : { 
>         "properties" : { 
>             "<column_name>" : { 
>                 "type" : ... 
>             }, 
>             ... 
>     } 
> } 
>
> I wasn't able to apply settings using a nested Java Map<String,Object> 
> structure, but I'm happy with supplying the JSON. 
>
> Cheers 
> -Lorrin 
>
> On 11 Jan., 12:53, "David Pilato" <[email protected]> wrote: 
> > Hi Lorrin, 
> > 
> > Have a look here :
> https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/el... 
> > arch/river/rss/AbstractRssRiverTest.java 
> > Create the index with an abstract mapping() method 
> > 
> > And here :
> https://github.com/dadoonet/rssriver/blob/master/src/test/java/org/el... 
> > arch/river/rss/RssRiverTest.java 
> > (for an implementation of the mapping() method) 
> > 
> > HTH 
> > David. 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > -----Message d'origine----- 
> > > De : [email protected] <javascript:> 
> > > [mailto:[email protected] <javascript:>] De la part de 
> Lorrin Nelson 
> > > Envoyé : mercredi 11 janvier 2012 20:00 
> > > À : elasticsearch 
> > > Objet : How to definemappingsusingJava API 
> > 
> > > Could someone share a working example ofusingthe Java API to define 
> > > typemappings? 
> > 
> > > I'm trying things like: 
> > > Settings.Builder indexSettings = 
> > > ImmutableSettings.settingsBuilder().loadFromSource( 
> > > XContentFactory.jsonBuilder() 
> > >                                     .startObject() 
> > >                                         .startObject("settings") 
> > >                                             .startObject("index") 
> > 
> > > .field("number_of_shards","BOGUS") 
> > >                                             .endObject() 
> > >                                         .endObject() 
> > >                                         .startObject("mappings") 
> > 
> > > .startObject("my_type_name") 
> > 
> > > .startObject("sequence") 
> > >                                                     .field("type", 
> > > "boolean") 
> > >                                                 .endObject() 
> > 
> > > .startObject("message.text") 
> > >                                                     .field("type", 
> > > "string") 
> > >                                                     .field("index", 
> > > "no") 
> > >                                                 .endObject() 
> > >                                             .endObject() 
> > >                                         .endObject() 
> > >                                     .endObject().string()); 
> > 
> > > CreateIndexResponse createIndexResponse = client.admin().indices() 
> > >                 .prepareCreate(newSlice).setSettings(indexSettings) 
> > >                 .execute().actionGet(); 
> > 
> > > I haven't managed to twiddle the builder structure such that they take 
> > > effect. E.g. message.text is searchable despite not being index, 
> > > sequence accepts numbers despite being boolean, and number_of_shards 
> > > being set to BOGUS doesn't produce any errors. 
> > 
> > > Thanks 
> > > -Lorrin

-- 
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/12cd2570-66dd-4934-9daa-7f06d0879208%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to