diff options
Diffstat (limited to 'config-model/src/main/java/com/yahoo/schema/fieldoperation/RankTypeOperation.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/schema/fieldoperation/RankTypeOperation.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/RankTypeOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/RankTypeOperation.java new file mode 100644 index 00000000000..4a43a907549 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/schema/fieldoperation/RankTypeOperation.java @@ -0,0 +1,43 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.schema.fieldoperation; + +import com.yahoo.schema.document.RankType; +import com.yahoo.schema.document.SDField; +import com.yahoo.schema.Index; + +/** + * @author Einar M R Rosenvinge + */ +public class RankTypeOperation implements FieldOperation { + + private String indexName; + private RankType type; + + public String getIndexName() { + return indexName; + } + public void setIndexName(String indexName) { + this.indexName = indexName; + } + + public RankType getType() { + return type; + } + public void setType(RankType type) { + this.type = type; + } + + public void apply(SDField field) { + if (indexName == null) { + field.setRankType(type); // Set default if the index is not specified. + } else { + Index index = field.getIndex(indexName); + if (index == null) { + index = new Index(indexName); + field.addIndex(index); + } + index.setRankType(type); + } + } + +} |