Making the switch from ES2 to ES6 and having a serious problem. Whenever I index a record with an id that contains a + symbol, Elasticsearch replaces the + with a space. The “id” field is correct, but the “_id” field contains a space.
Later, when I search for data and retrieve the key, I have a mismatch in my document store (dynamo) because the + have been replaced. In other words, by modifying the primary key used across databases, it makes it difficult to link the records.
Is it possible to escape the + so that _id is stored with the value I want? I’ve tried \ + or %2B for the +, and other variations but it does not work. I also tried changing the mapping on the index but nothing seems to work and I got an error trying to change _id field to a keyword.
Any tips for this? It seems like such a simple thing to store a symbol as part of the string, but ES6 is making it painful.
Not sure if it matters, but I’m using the Java Rest 6 client for all operations. Below is simple sample code to reproduce this:
RestHighLevelClient client = new RestHighLevelClient(...);
IndexRequest request = new IndexRequest("test", "test", "+1234");
request.source("{}", XContentType.JSON);
client.index(request,RequestOptions.DEFAULT);
And the data in ES:
GET test/_search
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": " 1234",
"_score": 1,
"_source": {}
}
]
}
}
Note the space and lack of + in the "_id" field.