fwiw, I fixed my issue below by using prepareCreate().setSource() - rather 
than .setSettings() with idx config in the following format:

{"settings"  : {
  "index": {
    "number_of_shards"  : 1,
    "number_of_replicas": 0,
    "analysis"          : {
      "analyzer": {
        "lowercase_keyword": {
          "tokenizer": "keyword",
          "filter"   : ["lowercase"]
        }
      }
    }
  }
}, "mappings": {
  "type1": {
    "properties": {
      "name": {
        "type" : "string",
        "index": "not_analyzed"
      }
    }
  }
}}



On Thursday, March 13, 2014 9:58:56 AM UTC-7, Nikita Tovstoles wrote:
>
> Hi, Kevin:
>
> Create Index 
> ref<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html#mappings>says
>  mappings can be included in index settings JSON. Are you saying that's 
> not supported by the Java client? (Fwiw, I am seeing the same - just wanted 
> to confirm):
>  the following settings successfully create index with predefined mappings 
> when using curl put /idx -d @settings.json but not when fed to java client 
> like so:
>
>
>         Settings settings = 
> ImmutableSettings.settingsBuilder().loadFromClasspath("es_admin_idx_settings.json").build();
>         return 
> getClient().admin().indices().prepareCreate(idxName).setSettings(settings).execute();
>
> INFO metadata:114 - [Seth] [idx-elasticsearchserviceintegrationtest] 
> creating index, cause [api], shards [2]/[0], mappings [] //EMPTY MAPPINGS
>
> {
>   "index"   : {
>     "number_of_shards"  : 1,
>     "number_of_replicas": 0
>   },
>   "mappings": {
>     "eligibility_criteria": {
>       "properties": {
>         "name": {
>           "type"  : "string",
>           "fields": {
>             "raw": {
>               "type" : "string",
>               "index": "not_analyzed"
>             }
>           }
>         }
>       }
>     }
>   }
> }
>
>
> On Tuesday, February 4, 2014 5:00:30 PM UTC-8, Kevin Wang wrote:
>>
>> The index request is used to index document, you should use put mapping 
>> request.
>>
>> e,g,
>> PutMappingResponse response = 
>> client.admin().indices().preparePutMapping(INDEX).setType(INDEX_TYPE).setSource(source).get();
>>
>>
>> On Wednesday, February 5, 2014 1:27:41 AM UTC+11, Doru Sular wrote:
>>>
>>> Hi guys,
>>>
>>> I am trying to create an index with the following code:
>>>     XContentBuilder source = XContentFactory.jsonBuilder().startObject()
>>> //
>>>                 .startObject("settings")
>>>                 .field("number_of_shards", 1)
>>>                 .endObject()// end settings
>>>                 .startObject("mappings")
>>>                 .startObject(INDEX_TYPE)//
>>>                 .startObject("properties")//
>>>                 .startObject("user")
>>>                 .field("type", "string") // start user
>>>                 .field("store", "yes")
>>>                 .field("index", "analyzed")//
>>>                 .endObject()// end user
>>>                 .startObject("postDate")//
>>>                 .field("type", "date")
>>>                 .field("store", "yes")
>>>                 .field("index", "analyzed")//
>>>                 .endObject()// end post date
>>>                 .startObject("message") //
>>>                 .field("type", "string")
>>>                 .field("store", "yes")
>>>                 .field("index", "not_analyzed")
>>>                 .endObject() // end user field
>>>                 .endObject() // end properties
>>>                 .endObject() // end index type
>>>                 .endObject() // end mappings
>>>                 .endObject(); // end the container object
>>>
>>>         IndexResponse response = this.client.prepareIndex(INDEX,INDEX_TYPE
>>> ).setSource(source)
>>>                 .setType(INDEX_TYPE).execute()
>>>                 .actionGet();
>>>
>>>
>>> I want to have the "message" field not analyzed, because later I want to 
>>> use facets to obtain unique messages.
>>> Unfortunately my code seems to add just a document in index with the 
>>> following structure:
>>> {
>>>   "settings": {
>>>     "number_of_shards": 1
>>>   },
>>>   "mappings": {
>>>     "tweet": {
>>>       "properties": {
>>>         "user": {
>>>           "type": "string",
>>>           "store": "yes",
>>>           "index": "analyzed"
>>>         },
>>>         "postDate": {
>>>           "type": "date",
>>>           "store": "yes",
>>>           "index": "analyzed"
>>>         },
>>>         "message": {
>>>           "type": "string",
>>>           "store": "yes",
>>>           "index": "not_analyzed"
>>>         }
>>>       }
>>>     }
>>>   }
>>> }
>>>
>>> Please help me to spot the error, it seems that mapping are not created.
>>> Thank you very much,
>>> Doru
>>>
>>>

-- 
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/8d0946a7-be01-4962-bfbb-f43ac303275a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to