Create a conditional mapping (enabled = false) on a single field based on field value

Hey team,

I have a use case in my application where a list of items called Descriptors are generated. These are filtered for a specific prefix "descsearch" and only these are being sent to the index and everything worked fine.

However due to a business change we now want ALL descriptors to be sent to the index to be returned by searches, (though the "descsearch" prefixed ones should be the only searchable ones).

When I make this change I am running into a mapping explosion issue because all of the NON prefixed descriptors are dynamically generated. Raising the mapping limit does not solve this issue and is causing other issues.

Type: mapper_parsing_exception Reason: "failed to parse" CausedBy: "Type: illegal_argument_exception Reason: "Limit of total fields [2000] has been exceeded while adding new fields [2]"

The solution I am trying to implement is to only have the "descsearch" prefixed descriptors to be searchable (enabled = true) and I don't want ES to worry about mapping any of the other descriptors (set them to enabled = false).

In other words, on my descriptors field, I want to introduce a conditional that checks if the item has the prefix, and if it does we want enabled = true, otherwise we want enabled = false.

Is there any way to achieve this using only one field or does there need to be two separate fields?

If you only want fields whose names start with descsearch to be searchable and all other fields to not be indexed you can use an index template to specify this.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.