001
014
015 package com.liferay.portal.kernel.search.generic;
016
017 import com.liferay.portal.kernel.search.BaseQueryImpl;
018 import com.liferay.portal.kernel.search.query.QueryVisitor;
019
020 import java.util.Arrays;
021 import java.util.Collection;
022 import java.util.HashMap;
023 import java.util.HashSet;
024 import java.util.Map;
025 import java.util.Set;
026
027
030 public class MultiMatchQuery extends BaseQueryImpl {
031
032 public MultiMatchQuery(String value) {
033 _value = value;
034 }
035
036 @Override
037 public <T> T accept(QueryVisitor<T> queryVisitor) {
038 return queryVisitor.visitQuery(this);
039 }
040
041 public void addField(String field) {
042 _fields.add(field);
043 }
044
045 public void addFields(Collection<String> fields) {
046 _fields.addAll(fields);
047 }
048
049 public void addFields(String... fields) {
050 _fields.addAll(Arrays.asList(fields));
051 }
052
053 public String getAnalyzer() {
054 return _analyzer;
055 }
056
057 public Float getCutOffFrequency() {
058 return _cutOffFrequency;
059 }
060
061 public Set<String> getFields() {
062 return _fields;
063 }
064
065 public Map<String, Float> getFieldsBoosts() {
066 return _fieldsBoosts;
067 }
068
069 public String getFuzziness() {
070 return _fuzziness;
071 }
072
073 public MatchQuery.RewriteMethod getFuzzyRewriteMethod() {
074 return _fuzzyRewriteMethod;
075 }
076
077 public Integer getMaxExpansions() {
078 return _maxExpansions;
079 }
080
081 public String getMinShouldMatch() {
082 return _minShouldMatch;
083 }
084
085 public MatchQuery.Operator getOperator() {
086 return _operator;
087 }
088
089 public Integer getPrefixLength() {
090 return _prefixLength;
091 }
092
093 public Integer getSlop() {
094 return _slop;
095 }
096
097 public Float getTieBreaker() {
098 return _tieBreaker;
099 }
100
101 public Type getType() {
102 return _type;
103 }
104
105 public String getValue() {
106 return _value;
107 }
108
109 public MatchQuery.ZeroTermsQuery getZeroTermsQuery() {
110 return _zeroTermsQuery;
111 }
112
113 public boolean isFieldBoostsEmpty() {
114 return _fieldsBoosts.isEmpty();
115 }
116
117 public boolean isFieldsEmpty() {
118 return _fields.isEmpty();
119 }
120
121 public Boolean isLenient() {
122 return _lenient;
123 }
124
125 public void setAnalyzer(String analyzer) {
126 _analyzer = analyzer;
127 }
128
129 public void setCutOffFrequency(Float cutOffFrequency) {
130 _cutOffFrequency = cutOffFrequency;
131 }
132
133 public void setFuzziness(String fuzziness) {
134 _fuzziness = fuzziness;
135 }
136
137 public void setFuzzyRewriteMethod(
138 MatchQuery.RewriteMethod fuzzyRewriteMethod) {
139
140 _fuzzyRewriteMethod = fuzzyRewriteMethod;
141 }
142
143 public void setLenient(Boolean lenient) {
144 _lenient = lenient;
145 }
146
147 public void setMaxExpansions(Integer maxExpansions) {
148 _maxExpansions = maxExpansions;
149 }
150
151 public void setMinShouldMatch(String minShouldMatch) {
152 _minShouldMatch = minShouldMatch;
153 }
154
155 public void setOperator(MatchQuery.Operator operator) {
156 _operator = operator;
157 }
158
159 public void setPrefixLength(Integer prefixLength) {
160 _prefixLength = prefixLength;
161 }
162
163 public void setSlop(Integer slop) {
164 _slop = slop;
165 }
166
167 public void setTieBreaker(Float tieBreaker) {
168 _tieBreaker = tieBreaker;
169 }
170
171 public void setType(Type type) {
172 _type = type;
173 }
174
175 public void setZeroTermsQuery(MatchQuery.ZeroTermsQuery zeroTermsQuery) {
176 _zeroTermsQuery = zeroTermsQuery;
177 }
178
179 public enum Type {
180
181 BEST_FIELDS, CROSS_FIELDS, MOST_FIELDS, PHRASE, PHRASE_PREFIX
182
183 }
184
185 private String _analyzer;
186 private Float _cutOffFrequency;
187 private final Set<String> _fields = new HashSet<>();
188 private final Map<String, Float> _fieldsBoosts = new HashMap<>();
189 private String _fuzziness;
190 private MatchQuery.RewriteMethod _fuzzyRewriteMethod;
191 private Boolean _lenient;
192 private Integer _maxExpansions;
193 private String _minShouldMatch;
194 private MatchQuery.Operator _operator;
195 private Integer _prefixLength;
196 private Integer _slop;
197 private Float _tieBreaker;
198 private Type _type;
199 private final String _value;
200 private MatchQuery.ZeroTermsQuery _zeroTermsQuery;
201
202 }