001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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    /**
021     * @author Michael C. Han
022     */
023    public class MatchQuery extends BaseQueryImpl {
024    
025            public MatchQuery(String field, String value) {
026                    _field = field;
027                    _value = value;
028            }
029    
030            @Override
031            public <T> T accept(QueryVisitor<T> queryVisitor) {
032                    return queryVisitor.visitQuery(this);
033            }
034    
035            public String getAnalyzer() {
036                    return _analyzer;
037            }
038    
039            public Float getCutOffFrequency() {
040                    return _cutOffFrequency;
041            }
042    
043            public String getField() {
044                    return _field;
045            }
046    
047            public Float getFuzziness() {
048                    return _fuzziness;
049            }
050    
051            public RewriteMethod getFuzzyRewriteMethod() {
052                    return _fuzzyRewriteMethod;
053            }
054    
055            public Integer getMaxExpansions() {
056                    return _maxExpansions;
057            }
058    
059            public String getMinShouldMatch() {
060                    return _minShouldMatch;
061            }
062    
063            public Operator getOperator() {
064                    return _operator;
065            }
066    
067            public Integer getPrefixLength() {
068                    return _prefixLength;
069            }
070    
071            public Integer getSlop() {
072                    return _slop;
073            }
074    
075            public Type getType() {
076                    return _type;
077            }
078    
079            public String getValue() {
080                    return _value;
081            }
082    
083            public ZeroTermsQuery getZeroTermsQuery() {
084                    return _zeroTermsQuery;
085            }
086    
087            public Boolean isFuzzyTranspositions() {
088                    return _fuzzyTranspositions;
089            }
090    
091            public Boolean isLenient() {
092                    return _lenient;
093            }
094    
095            public void setAnalyzer(String analyzer) {
096                    _analyzer = analyzer;
097            }
098    
099            public void setCutOffFrequency(Float cutOffFrequency) {
100                    _cutOffFrequency = cutOffFrequency;
101            }
102    
103            public void setFuzziness(Float fuzziness) {
104                    _fuzziness = fuzziness;
105            }
106    
107            public void setFuzzyRewriteMethod(RewriteMethod fuzzyRewriteMethod) {
108                    _fuzzyRewriteMethod = fuzzyRewriteMethod;
109            }
110    
111            public void setFuzzyTranspositions(Boolean fuzzyTranspositions) {
112                    _fuzzyTranspositions = fuzzyTranspositions;
113            }
114    
115            public void setLenient(Boolean lenient) {
116                    _lenient = lenient;
117            }
118    
119            public void setMaxExpansions(Integer maxExpansions) {
120                    _maxExpansions = maxExpansions;
121            }
122    
123            public void setMinShouldMatch(String minShouldMatch) {
124                    _minShouldMatch = minShouldMatch;
125            }
126    
127            public void setOperator(Operator operator) {
128                    _operator = operator;
129            }
130    
131            public void setPrefixLength(Integer prefixLength) {
132                    _prefixLength = prefixLength;
133            }
134    
135            public void setSlop(Integer slop) {
136                    _slop = slop;
137            }
138    
139            public void setType(Type type) {
140                    _type = type;
141            }
142    
143            public void setZeroTermsQuery(ZeroTermsQuery zeroTermsQuery) {
144                    _zeroTermsQuery = zeroTermsQuery;
145            }
146    
147            public enum Operator {
148    
149                    AND, OR
150    
151            }
152    
153            public enum RewriteMethod {
154    
155                    CONSTANT_SCORE_AUTO, CONSTANT_SCORE_BOOLEAN, CONSTANT_SCORE_FILTER,
156                    SCORING_BOOLEAN, TOP_TERMS_N, TOP_TERMS_BOOST_N
157    
158            }
159    
160            public enum Type {
161    
162                    BOOLEAN, PHRASE, PHRASE_PREFIX
163    
164            }
165    
166            public enum ZeroTermsQuery {
167    
168                    ALL, NONE
169    
170            }
171    
172            private String _analyzer;
173            private Float _cutOffFrequency;
174            private final String _field;
175            private Float _fuzziness;
176            private RewriteMethod _fuzzyRewriteMethod;
177            private Boolean _fuzzyTranspositions;
178            private Boolean _lenient;
179            private Integer _maxExpansions;
180            private String _minShouldMatch;
181            private Operator _operator;
182            private Integer _prefixLength;
183            private Integer _slop;
184            private Type _type;
185            private final String _value;
186            private ZeroTermsQuery _zeroTermsQuery;
187    
188    }