diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-04-12 09:25:41 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-04-12 09:25:46 +0200 |
commit | 787fa05cebd66820136372164b7e1b2805f9f061 (patch) | |
tree | 264c403f21b98bc5d4d1d65f0b49f378b4184b3b /config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation | |
parent | 015ade7cd232f217dd964da037ab202731b37cef (diff) |
Control cased/uncased in dictionary setting
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/DictionaryOperation.java | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/DictionaryOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/DictionaryOperation.java index ce7c5a71a21..70b0706df29 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/DictionaryOperation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/DictionaryOperation.java @@ -11,25 +11,30 @@ import com.yahoo.searchdefinition.document.SDField; * @author baldersheim */ public class DictionaryOperation implements FieldOperation { - private final Dictionary.Type type; + public enum Operation { HASH, BTREE, CASED, UNCASED } + private final Operation operation; - public DictionaryOperation(Dictionary.Type type) { - this.type = type; + public DictionaryOperation(Operation type) { + this.operation = type; } @Override public void apply(SDField field) { - Dictionary prev = field.getDictionary(); - if (prev == null) { - field.setDictionary(new Dictionary(type)); - } else if ((prev.getType() == Dictionary.Type.BTREE && type == Dictionary.Type.HASH) || - (prev.getType() == Dictionary.Type.HASH && type == Dictionary.Type.BTREE)) - { - field.setDictionary(new Dictionary(Dictionary.Type.BTREE_AND_HASH)); - } else { - if (prev.getType() != type) { - throw new IllegalArgumentException("Can not combine previous dictionary setting " + prev.getType() + - " with current " + type); - } + Dictionary dictionary = field.getOrSetDictionary(); + switch (operation) { + case HASH: + dictionary.updateType(Dictionary.Type.HASH); + break; + case BTREE: + dictionary.updateType(Dictionary.Type.BTREE); + break; + case CASED: + dictionary.updateMatch(Dictionary.Match.CASED); + break; + case UNCASED: + dictionary.updateMatch(Dictionary.Match.UNCASED); + break; + default: + throw new IllegalArgumentException("Unhandled operation " + operation); } } } |