We have a setup where some fields are analyzed in multiple ways: with the standard
analyzer and a custom analyzer my_analyzer
that preserves punctuation and capitalisation. We want to be able to perform prefix search on both fields. As such we want to apply index_prefixes
to the relevant fields. We have tried the following mapping
{
"mapping": {
"properties": {
"field1": {
"type": "text",
"index_prefixes": {},
"fields": {
"exact": {
"type": "text"
"analyzer": "my_analyzer",
"index_prefixes": {}
}
}
},
"field2": {
"type": "text",
"index_prefixes": {},
"fields": {
"exact": {
"type": "text"
"analyzer": "my_analyzer",
"index_prefixes": {}
}
}
}
}
}
}
But creating an index with this mapping produces:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Field [exact._index_prefix] is defined twice."
}
],
"type": "illegal_argument_exception",
"reason": "Field [exact._index_prefix] is defined twice."
},
"status": 400
}
If we remove the index_prefixes
from the exact
fields, the index creation succeeds. In other words, change the mapping to:
{
"mapping": {
"properties": {
"field1": {
"type": "text",
"index_prefixes": {},
"fields": {
"exact": {
"type": "text"
"analyzer": "my_analyzer"
}
}
},
"field2": {
"type": "text",
"index_prefixes": {},
"fields": {
"exact": {
"type": "text"
"analyzer": "my_analyzer"
}
}
}
}
}
}
But are prefixes indexed on field1.exact
and field2.exact
if index_prefixes
is only present on the field1
and field2
? If not, what is the correct way to do this? The documentation does not mention anything about fields.