EDIT: I figured out what I did wrong below. The Javadocs for addMapping() say the following:
/**
* Adds mapping that will be added when the index gets created.
*
* @param type The mapping type
* @param source The mapping source
*/
public CreateIndexRequestBuilder addMapping(String type, String source) {
request.mapping(type, source);
return this;
}
... and I was taking "mapping type" to mean the field within the document, not the document type itself. Is that a standard in the Elasticsearch naming conventions and I just misunderstood, or are terms used a bit loosely?
==============================================
Also, I just tried your suggestion (I think I had tried that already after reading it elsewhere), and the index now looks like the below - note how the target field whose mapping I'm trying to modify is added outside of the main mapping block - it doesn't appear to go in the correct place. In fact, I found that those mapping properties are not applied to it after this index modification is made.
Do let me know if the below looks correct to you - it doesn't to me, but then I'm not familiar with what a proper index should look like after its mapping has been modified (I did a search for a value of "Section" and it returned no results; however, when I searched for it in lower case, it appeared; our default Elasticsearch config file is set up to convert to lowercase during analysis, so those map modifications are not being applied - as part of this test, I rebuild the index from scratch, so if that mapping change were working, I'd see it):
{
"patdocument-50" : {
"aliases" : { },
"mappings" : {
"patdocument" : {
"properties" : {
"AuthorName" : {
"type" : "string"
},
"CreatedDate" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"DateOfService" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"Deleted" : {
"type" : "boolean"
},
"DocumentName" : {
"type" : "string"
},
"Draft" : {
"type" : "boolean"
},
"Id" : {
"type" : "long"
},
"OwnerUserId" : {
"type" : "long"
},
"PatientId" : {
"type" : "long"
},
"PracticeId" : {
"type" : "long"
},
"Sections" : {
"type" : "string"
},
"Text" : {
"type" : "string"
}
}
},
"Sections" : {
"properties" : {
"Sections" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
},
"settings" : {
"index" : {
"creation_date" : "1447825627556",
"uuid" : "Ht0FqKIkTN-EOSgr_rGFhg",
"number_of_replicas" : "0",
"number_of_shards" : "1",
"version" : {
"created" : "1050299"
}
}
},
"warmers" : { }
}
}