All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.redislabs.lettusearch.index.field.FieldOptions Maven / Gradle / Ivy

There is a newer version: 3.1.2
Show newest version
package com.redislabs.lettusearch.index.field;

import static com.redislabs.lettusearch.protocol.CommandKeyword.NOINDEX;
import static com.redislabs.lettusearch.protocol.CommandKeyword.NOSTEM;
import static com.redislabs.lettusearch.protocol.CommandKeyword.PHONETIC;
import static com.redislabs.lettusearch.protocol.CommandKeyword.SEPARATOR;
import static com.redislabs.lettusearch.protocol.CommandKeyword.SORTABLE;
import static com.redislabs.lettusearch.protocol.CommandKeyword.WEIGHT;

import com.redislabs.lettusearch.RediSearchArgument;
import com.redislabs.lettusearch.protocol.RediSearchCommandArgs;

import lombok.Builder;
import lombok.Builder.Default;
import lombok.Data;

@Data
@Builder
public class FieldOptions implements RediSearchArgument {

    @Default
    private FieldType type = FieldType.Text;
    private boolean sortable;
    private boolean noIndex;
    private Double weight;
    private boolean noStem;
    private PhoneticMatcher matcher;
    private String separator;

    @Override
    public  void build(RediSearchCommandArgs args) {
        args.add(type.getKeyword());
        if (noStem) {
            args.add(NOSTEM);
        }
        if (weight != null) {
            args.add(WEIGHT);
            args.add(weight);
        }
        if (matcher != null) {
            args.add(PHONETIC);
            args.add(matcher.getCode());
        }
        if (separator != null) {
            args.add(SEPARATOR);
            args.add(separator);
        }
        if (sortable) {
            args.add(SORTABLE);
        }
        if (noIndex) {
            args.add(NOINDEX);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy