Hi!
Disclaimer: This question is related to Java and a bit Java Spring. This question isn't focusing on Java but the concept of field mapping.
I'd like to index instances of this Java class:
public class MyDoc {
// Other fields omitted
@Field(type = FieldType.Object, store = true)
private Map<String, String> fields;
}
This class simply contains a classical map called fields. I'd like to have every value of the map be full-text-indexed. The @Field-Attribute tells the Java-Spring library to handle this field as an Object and to store the property.
So what I'd like to see is that when receiving a structure like this ...
{
"fields": {
"field1": "This should be"
}
}
... Elasticsearch will map field1 and field2 dynamically as full-text-searchable. I expect Elasticsearch to generate this mapping dynamically:
"mappings": {
"document": {
"properties": {
"fields": {
"properties": {
"field1": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
But that's not what happens. When I index a document for the first time via my Java application, the dynamically generated mapping looks like this:
"mappings": {
"document": {
"properties": {
"fields": {
"type": "object"
}
}
}
}
Even more strange, the indexed document does not contain the fields:
{
"_index": "myindex",
"_type": "document",
"_id": "1401529699",
"_version": 1,
"found": true,
"_source": {
"id": "1401529699"
}
}
I suspect that I need to create a custom mapping that instructs elastic to index every value of the Map field, is that correct?