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 Float 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 MatchQuery.RewriteMethod getRewriteMethod() {
094 return _rewriteMethod;
095 }
096
097 public Integer getSlop() {
098 return _slop;
099 }
100
101 public Float getTieBreaker() {
102 return _tieBreaker;
103 }
104
105 public Type getType() {
106 return _type;
107 }
108
109 public String getValue() {
110 return _value;
111 }
112
113 public MatchQuery.ZeroTermsQuery getZeroTermsQuery() {
114 return _zeroTermsQuery;
115 }
116
117 public boolean isFieldBoostsEmpty() {
118 return _fieldsBoosts.isEmpty();
119 }
120
121 public boolean isFieldsEmpty() {
122 return _fields.isEmpty();
123 }
124
125 public Boolean isLenient() {
126 return _lenient;
127 }
128
129 public void setAnalyzer(String analyzer) {
130 _analyzer = analyzer;
131 }
132
133 public void setCutOffFrequency(Float cutOffFrequency) {
134 _cutOffFrequency = cutOffFrequency;
135 }
136
137 public void setFuzziness(Float fuzziness) {
138 _fuzziness = fuzziness;
139 }
140
141 public void setFuzzyRewriteMethod(
142 MatchQuery.RewriteMethod fuzzyRewriteMethod) {
143
144 _fuzzyRewriteMethod = fuzzyRewriteMethod;
145 }
146
147 public void setLenient(Boolean lenient) {
148 _lenient = lenient;
149 }
150
151 public void setMaxExpansions(Integer maxExpansions) {
152 _maxExpansions = maxExpansions;
153 }
154
155 public void setMinShouldMatch(String minShouldMatch) {
156 _minShouldMatch = minShouldMatch;
157 }
158
159 public void setOperator(MatchQuery.Operator operator) {
160 _operator = operator;
161 }
162
163 public void setPrefixLength(Integer prefixLength) {
164 _prefixLength = prefixLength;
165 }
166
167 public void setRewriteMethod(MatchQuery.RewriteMethod rewriteMethod) {
168 _rewriteMethod = rewriteMethod;
169 }
170
171 public void setSlop(Integer slop) {
172 _slop = slop;
173 }
174
175 public void setTieBreaker(Float tieBreaker) {
176 _tieBreaker = tieBreaker;
177 }
178
179 public void setType(Type type) {
180 _type = type;
181 }
182
183 public void setZeroTermsQuery(MatchQuery.ZeroTermsQuery zeroTermsQuery) {
184 _zeroTermsQuery = zeroTermsQuery;
185 }
186
187 public enum Type {
188
189 BEST_FIELDS, CROSS_FIELDS, MOST_FIELDS, PHRASE, PHRASE_PREFIX
190
191 }
192
193 private String _analyzer;
194 private Float _cutOffFrequency;
195 private final Set<String> _fields = new HashSet<>();
196 private final Map<String, Float> _fieldsBoosts = new HashMap<>();
197 private Float _fuzziness;
198 private MatchQuery.RewriteMethod _fuzzyRewriteMethod;
199 private Boolean _lenient;
200 private Integer _maxExpansions;
201 private String _minShouldMatch;
202 private MatchQuery.Operator _operator;
203 private Integer _prefixLength;
204 private MatchQuery.RewriteMethod _rewriteMethod;
205 private Integer _slop;
206 private Float _tieBreaker;
207 private Type _type;
208 private final String _value;
209 private MatchQuery.ZeroTermsQuery _zeroTermsQuery;
210
211 }