WARNING: Version 5.x has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Naming conventions
editNaming conventions
editCurrently, the name of a field cannot contain a .
in Elasticsearch due to the potential for ambiguity with
a field that is mapped as a multi field.
In these cases, NEST allows the call to go to Elasticsearch, deferring the naming conventions to the server side and,
in the case of a .
in a field name, a 400 Bad Response
is returned with a server error indicating the reason
var createIndexResponse = _client.CreateIndex("random-" + Guid.NewGuid().ToString().ToLowerInvariant(), c => c .Mappings(m => m .Map("type-with-dot", mm => mm .Properties(p => p .String(s => s .Name("name-with.dot") ) ) ) ) );
The response is not valid
createIndexResponse.ShouldNotBeValid();
DebugInformation
provides an audit trail of information to help diagnose the issue
createIndexResponse.DebugInformation.Should().NotBeNullOrEmpty();
ServerError
contains information about the response from Elasticsearch
createIndexResponse.ServerError.Should().NotBeNull(); createIndexResponse.ServerError.Status.Should().Be(400); createIndexResponse.ServerError.Error.Should().NotBeNull(); createIndexResponse.ServerError.Error.RootCause.Should().NotBeNullOrEmpty(); var rootCause = createIndexResponse.ServerError.Error.RootCause[0];
We can see that the underlying reason is a .
in the field name "name-with.dot"
rootCause.Reason.Should().Be("Field name [name-with.dot] cannot contain '.'"); rootCause.Type.Should().Be("mapper_parsing_exception");