001: /*
002: * Copyright 2004-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.compass.core.engine;
018:
019: import java.io.Reader;
020:
021: import org.compass.core.Resource;
022: import org.compass.core.engine.SearchEngineQuery.SearchEngineSpanQuery;
023:
024: /**
025: * @author kimchy
026: */
027: public interface SearchEngineQueryBuilder {
028:
029: public static interface SearchEngineToQuery {
030:
031: SearchEngineQuery toQuery();
032: }
033:
034: public static interface SearchEngineBooleanQueryBuilder extends
035: SearchEngineToQuery {
036:
037: SearchEngineBooleanQueryBuilder addMust(SearchEngineQuery query);
038:
039: SearchEngineBooleanQueryBuilder addMustNot(
040: SearchEngineQuery query);
041:
042: SearchEngineBooleanQueryBuilder addShould(
043: SearchEngineQuery query);
044: }
045:
046: public static interface SearchEngineMultiPhraseQueryBuilder extends
047: SearchEngineToQuery {
048:
049: SearchEngineMultiPhraseQueryBuilder setSlop(int slop);
050:
051: SearchEngineMultiPhraseQueryBuilder add(String value);
052:
053: SearchEngineMultiPhraseQueryBuilder add(String value,
054: int position);
055:
056: SearchEngineMultiPhraseQueryBuilder add(String[] values);
057:
058: SearchEngineMultiPhraseQueryBuilder add(String[] values,
059: int position);
060: }
061:
062: public static interface SearchEngineQueryStringBuilder extends
063: SearchEngineToQuery {
064:
065: SearchEngineQueryStringBuilder setAnalyzer(String analyzer);
066:
067: SearchEngineQueryStringBuilder setAnalyzerByAlias(String alias);
068:
069: SearchEngineQueryStringBuilder setDefaultSearchProperty(
070: String defaultSearchProperty);
071:
072: SearchEngineQueryStringBuilder useAndDefaultOperator();
073:
074: SearchEngineQueryStringBuilder useOrDefaultOperator();
075:
076: SearchEngineQueryStringBuilder forceAnalyzer();
077:
078: SearchEngineQueryStringBuilder setQueryParser(String queryParser);
079:
080: SearchEngineQueryStringBuilder useSpellCheck();
081: }
082:
083: public static interface SearchEngineMultiPropertyQueryStringBuilder
084: extends SearchEngineToQuery {
085:
086: SearchEngineMultiPropertyQueryStringBuilder setAnalyzer(
087: String analyzer);
088:
089: SearchEngineMultiPropertyQueryStringBuilder setAnalyzerByAlias(
090: String alias);
091:
092: SearchEngineMultiPropertyQueryStringBuilder add(
093: String resourcePropertyName);
094:
095: SearchEngineMultiPropertyQueryStringBuilder useAndDefaultOperator();
096:
097: SearchEngineQueryBuilder.SearchEngineMultiPropertyQueryStringBuilder forceAnalyzer();
098:
099: SearchEngineMultiPropertyQueryStringBuilder setQueryParser(
100: String queryParser);
101:
102: SearchEngineQueryBuilder.SearchEngineMultiPropertyQueryStringBuilder useSpellCheck();
103: }
104:
105: public static interface SearchEngineQuerySpanNearBuilder {
106:
107: SearchEngineQuerySpanNearBuilder setSlop(int slop);
108:
109: SearchEngineQuerySpanNearBuilder setInOrder(boolean inOrder);
110:
111: SearchEngineQuerySpanNearBuilder add(String value);
112:
113: SearchEngineQuerySpanNearBuilder add(SearchEngineSpanQuery query);
114:
115: SearchEngineSpanQuery toQuery();
116: }
117:
118: public static interface SearchEngineQuerySpanOrBuilder {
119:
120: SearchEngineQuerySpanOrBuilder add(SearchEngineSpanQuery query);
121:
122: SearchEngineSpanQuery toQuery();
123: }
124:
125: public static interface SearchEngineMoreLikeThisQueryBuilder extends
126: SearchEngineToQuery {
127:
128: SearchEngineMoreLikeThisQueryBuilder setSubIndexes(
129: String[] subIndexes);
130:
131: SearchEngineMoreLikeThisQueryBuilder setAliases(String[] aliases);
132:
133: SearchEngineMoreLikeThisQueryBuilder setProperties(
134: String[] properties);
135:
136: SearchEngineMoreLikeThisQueryBuilder addProperty(String property);
137:
138: SearchEngineMoreLikeThisQueryBuilder setAnalyzer(String analyzer);
139:
140: SearchEngineMoreLikeThisQueryBuilder setBoost(boolean boost);
141:
142: SearchEngineMoreLikeThisQueryBuilder setMaxNumTokensParsed(
143: int maxNumTokensParsed);
144:
145: SearchEngineMoreLikeThisQueryBuilder setMaxQueryTerms(
146: int maxQueryTerms);
147:
148: SearchEngineMoreLikeThisQueryBuilder setMaxWordLen(
149: int maxWordLen);
150:
151: SearchEngineMoreLikeThisQueryBuilder setMinResourceFreq(
152: int minDocFreq);
153:
154: SearchEngineMoreLikeThisQueryBuilder setMinTermFreq(
155: int minTermFreq);
156:
157: SearchEngineMoreLikeThisQueryBuilder setMinWordLen(
158: int minWordLen);
159:
160: SearchEngineMoreLikeThisQueryBuilder setStopWords(
161: String[] stopWords);
162: }
163:
164: SearchEngineBooleanQueryBuilder bool();
165:
166: SearchEngineBooleanQueryBuilder bool(boolean disableCoord);
167:
168: SearchEngineMultiPhraseQueryBuilder multiPhrase(
169: String resourcePropertyName);
170:
171: SearchEngineQueryStringBuilder queryString(String queryString);
172:
173: SearchEngineMultiPropertyQueryStringBuilder multiPropertyQueryString(
174: String queryString);
175:
176: SearchEngineQuery wildcard(String resourcePropertyName,
177: String wildcard);
178:
179: SearchEngineQuery term(String resourcePropertyName, String value);
180:
181: SearchEngineQuery matchAll();
182:
183: SearchEngineQuery between(String resourcePropertyName, String low,
184: String high, boolean inclusive, boolean constantScore);
185:
186: SearchEngineQuery between(String resourcePropertyName, String low,
187: String high, boolean inclusive);
188:
189: SearchEngineQuery lt(String resourcePropertyName, String value);
190:
191: SearchEngineQuery le(String resourcePropertyName, String value);
192:
193: SearchEngineQuery gt(String resourcePropertyName, String value);
194:
195: SearchEngineQuery ge(String resourcePropertyName, String value);
196:
197: SearchEngineQuery prefix(String resourcePropertyName, String prefix);
198:
199: SearchEngineQuery fuzzy(String resourcePropertyName, String value);
200:
201: SearchEngineQuery fuzzy(String resourcePropertyName, String value,
202: float minimumSimilarity);
203:
204: SearchEngineQuery fuzzy(String resourcePropertyName, String value,
205: float minimumSimilarity, int prefixLength);
206:
207: SearchEngineSpanQuery spanEq(String resourcePropertyName,
208: String value);
209:
210: SearchEngineSpanQuery spanFirst(
211: SearchEngineSpanQuery searchEngineSpanQuery, int end);
212:
213: SearchEngineSpanQuery spanFirst(String resourcePropertyName,
214: String value, int end);
215:
216: SearchEngineQuerySpanNearBuilder spanNear(
217: String resourcePropertyName);
218:
219: SearchEngineSpanQuery spanNot(SearchEngineSpanQuery include,
220: SearchEngineSpanQuery exclude);
221:
222: SearchEngineQuerySpanOrBuilder spanOr();
223:
224: SearchEngineMoreLikeThisQueryBuilder moreLikeThis(
225: Resource idResource);
226:
227: SearchEngineMoreLikeThisQueryBuilder moreLikeThis(Reader reader);
228: }
|