Source Code Cross Referenced for CompassQueryBuilder.java in  » Search-Engine » compass-2.0 » org » compass » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Search Engine » compass 2.0 » org.compass.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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;
018:
019:        import java.io.Reader;
020:        import java.io.Serializable;
021:
022:        import org.compass.core.CompassQuery.CompassSpanQuery;
023:
024:        /**
025:         * <p>The query builder is used to construct {@link CompassQuery} programmatically.
026:         * Simple queries, like {@link #le(String,Object)}, will generate a {@link CompassQuery}.
027:         * More complex ones, will return their respective builder to continue and bulid them (like
028:         * {@link #multiPhrase(String)}). Combining {@link CompassQuery}s can be done using
029:         * the {@link #bool()} operation.
030:         *
031:         * <p>An example of building a query using the query builder:
032:         * <pre>
033:         * CompassQueryBuilder queryBuilder = session.createQueryBuilder();
034:         * queryBuilder.bool().addMust(queryBuilder.eq(&quot;name&quot;, &quot;jack&quot;)).addMust(queryBuilder.lt(&quot;birthdate&quot;, &quot;19500101&quot;))
035:         *      .toQuery().hits();
036:         * </pre>
037:         *
038:         * @author kimchy
039:         */
040:        public interface CompassQueryBuilder {
041:
042:            /**
043:             * A general interface for internal builders that will create a
044:             * {@link CompassQuery}.
045:             *
046:             * @author kimchy
047:             */
048:            public static interface ToCompassQuery {
049:
050:                /**
051:                 * Create the query.
052:                 */
053:                CompassQuery toQuery();
054:            }
055:
056:            /**
057:             * A boolean query builder. Used to construct query that will return hits
058:             * that are the matching boolean combinations of other queries.
059:             *
060:             * @author kimchy
061:             */
062:            public static interface CompassBooleanQueryBuilder extends
063:                    ToCompassQuery {
064:
065:                /**
066:                 * Hits must match the given query.
067:                 *
068:                 * @param query The query to add
069:                 * @return The current builder
070:                 */
071:                CompassBooleanQueryBuilder addMust(CompassQuery query);
072:
073:                /**
074:                 * Hits must not match the given query. Note that it is not possible to
075:                 * build a boolean query that only consists of must not queries.
076:                 *
077:                 * @param query The query to add
078:                 * @return The current builder
079:                 */
080:                CompassBooleanQueryBuilder addMustNot(CompassQuery query);
081:
082:                /**
083:                 * Hits should match the given query. For a boolean build query with two
084:                 * <code>should</code> subqueries, at least one of the queries must
085:                 * appear in the matching hits.
086:                 *
087:                 * @param query The query to add
088:                 * @return The current builder
089:                 */
090:                CompassBooleanQueryBuilder addShould(CompassQuery query);
091:            }
092:
093:            /**
094:             * A query builder that constructs a phrase query. A phrase query is used to
095:             * locate hits with terms within a certain distance from one another. The
096:             * distance is also called slop. For example, you can use it to search for
097:             * the values: java and london, which are near one another. "Near" is
098:             * measured using the slop, and a value of 1 means that they will be in a
099:             * distance of 1 other value from one another.
100:             * <p/>
101:             * The slop defaults to 0.
102:             *
103:             * @author kimchy
104:             */
105:            public static interface CompassMultiPhraseQueryBuilder extends
106:                    ToCompassQuery {
107:
108:                /**
109:                 * Sets the slop for the phrase query.
110:                 */
111:                CompassMultiPhraseQueryBuilder setSlop(int slop);
112:
113:                /**
114:                 * Adds a single value to the next position in the phrase.
115:                 */
116:                CompassMultiPhraseQueryBuilder add(Object value);
117:
118:                /**
119:                 * Adds a single value to the position given in the phrase.
120:                 */
121:                CompassMultiPhraseQueryBuilder add(Object value, int position);
122:
123:                /**
124:                 * Adds several values to the next position in the phrase.
125:                 */
126:                CompassMultiPhraseQueryBuilder add(Object[] values);
127:
128:                /**
129:                 * Adds several values to the position given in the phrase.
130:                 */
131:                CompassMultiPhraseQueryBuilder add(Object[] values, int position);
132:            }
133:
134:            /**
135:             * A query builder used to construct a query from a query string (i.e. +jack
136:             * +fang). The analyzer that will be used to analyze the query string and
137:             * the default search property (for search terms not prefixed with a
138:             * property name) can be set before calling the <code>toQuery</code>.
139:             *
140:             * @author kimchy
141:             */
142:            public static interface CompassQueryStringBuilder extends
143:                    ToCompassQuery {
144:
145:                /**
146:                 * Sets the analyzer that will be used to analyze the query string. Can
147:                 * be <code>null</code>. It is used when parsing a query string and
148:                 * has no effect when using a bulit in query (using the {@link CompassQuery}).
149:                 */
150:                CompassQueryStringBuilder setAnalyzer(String analyzer)
151:                        throws CompassException;
152:
153:                /**
154:                 * Sets te query parser lookup name that will be used to parse the query string.
155:                 */
156:                CompassQueryStringBuilder setQueryParser(String queryParser)
157:                        throws CompassException;
158:
159:                /**
160:                 * Uses the spell check for suggesting a query based on the query string.
161:                 */
162:                CompassQueryStringBuilder useSpellCheck()
163:                        throws CompassException;
164:
165:                /**
166:                 * Sets the analyzer that will be used to analyzer the query string. The
167:                 * analyzer will be built based on analyzer settings for the mapping definitions
168:                 * the define the alias. It means that if a certain property is associated with
169:                 * a specific analyzer, a per property analyzer will be built.
170:                 */
171:                CompassQueryStringBuilder setAnalyzerByAlias(String alias)
172:                        throws CompassException;
173:
174:                /**
175:                 * Sets the default search property for non prefixed terms in the query
176:                 * string. Can be <code>null</code>. It is used when parsing a query
177:                 * string and has no effect when using a bulit in query (using the
178:                 * {@link CompassQuery}).
179:                 */
180:                CompassQueryStringBuilder setDefaultSearchProperty(
181:                        String defaultSearchProperty);
182:
183:                /**
184:                 * Uses the and operator as the default operator instead of OR operator.
185:                 */
186:                CompassQueryStringBuilder useAndDefaultOperator();
187:
188:                /**
189:                 * Uses the OR operator as the default operator instead of AND operator.
190:                 */
191:                CompassQueryStringBuilder useOrDefaultOperator();
192:
193:                /**
194:                 * Forces the query string to only use the analyzer specificed (or configured)
195:                 * and not take into account any analyzers that might be specifiec within the mappings.
196:                 */
197:                CompassQueryStringBuilder forceAnalyzer();
198:            }
199:
200:            /**
201:             * Parses the query string into terms, which all of them are used against the given
202:             * resource property name / meta-data.
203:             * <p/>
204:             * If the query string breaks into two terms (term1 and term2), and we use {@link #add(String)}
205:             * to add two resource property names: title and body, the query will be expanded to:
206:             * <code>(title:term1 body:term1) (title:term2 body:term2)</code>. If {@link #useAndDefaultOperator()}
207:             * is called, the query will be: <code>+(title:term1 body:term1) +(title:term2 body:term2)</code>.
208:             *
209:             * @author kimchy
210:             */
211:            public static interface CompassMultiPropertyQueryStringBuilder
212:                    extends ToCompassQuery {
213:
214:                /**
215:                 * Sets the analyzer that will be used to analyze the query string. Can
216:                 * be <code>null</code>. It is used when parsing a query string and
217:                 * has no effect when using a bulit in query (using the {@link CompassQuery}).
218:                 */
219:                CompassMultiPropertyQueryStringBuilder setAnalyzer(
220:                        String analyzer);
221:
222:                /**
223:                 * Sets the analyzer that will be used to analyzer the query string. The
224:                 * analyzer will be build based on analyzer settings for the mapping definitions
225:                 * the define the alias. It means that if a certain property is associated with
226:                 * a specific analyzer, a per property analyzer will be built.
227:                 */
228:                CompassMultiPropertyQueryStringBuilder setAnalyzerByAlias(
229:                        String alias) throws CompassException;
230:
231:                /**
232:                 * Sets te query parser lookup name that will be used to parse the query string.
233:                 */
234:                CompassMultiPropertyQueryStringBuilder setQueryParser(
235:                        String queryParser) throws CompassException;
236:
237:                /**
238:                 * Uses the spell check for suggesting a query based on the query string.
239:                 */
240:                CompassMultiPropertyQueryStringBuilder useSpellCheck();
241:
242:                /**
243:                 * Adds another resource property name / meta-data that the query string will be executed against.
244:                 * <p/>
245:                 * The name can either be the actual resource property or meta-data value,
246:                 * or the path to the given resource property (alias.rProperty), or the
247:                 * class property (alias.cProperty) or the path to the meta-data
248:                 * (alias.cProperty.metaData)
249:                 *
250:                 * @param name The name of the resource property / meta-data.
251:                 */
252:                CompassMultiPropertyQueryStringBuilder add(String name);
253:
254:                /**
255:                 * If called, the query will be expanded to: <code>+(title:term1 body:term1) +(title:term2 body:term2)</code>
256:                 * (Instead of <code>(title:term1 body:term1) (title:term2 body:term2)</code>).
257:                 */
258:                CompassMultiPropertyQueryStringBuilder useAndDefaultOperator();
259:
260:                /**
261:                 * Forces the query parser to use the analyzer specified or confiugred and not
262:                 * analyzers that might be defined on different mappings.
263:                 */
264:                CompassMultiPropertyQueryStringBuilder forceAnalyzer();
265:            }
266:
267:            /**
268:             * A span near query builder. Matches spans which are near one another. One
269:             * can specify <i>slop</i>, the maximum number of intervening unmatched
270:             * positions, as well as whether matches are required to be in-order.
271:             * <p/>
272:             * <code>slop</code> defauls to <code>0</code> and <code>inOrder</code>
273:             * defaults to <code>true</code>.
274:             *
275:             * @author kimchy
276:             */
277:            public static interface CompassQuerySpanNearBuilder {
278:
279:                /**
280:                 * Sets the slop which is the distance allowed between spans.
281:                 */
282:                CompassQuerySpanNearBuilder setSlop(int slop);
283:
284:                /**
285:                 * Sets if the spans need to be in order.
286:                 */
287:                CompassQuerySpanNearBuilder setInOrder(boolean inOrder);
288:
289:                /**
290:                 * Adds a single value to the next span match.
291:                 */
292:                CompassQuerySpanNearBuilder add(Object value);
293:
294:                /**
295:                 * Adds a single span query to the next span match.
296:                 */
297:                CompassQuerySpanNearBuilder add(CompassSpanQuery query);
298:
299:                /**
300:                 * Returns the span near generated query.
301:                 */
302:                CompassSpanQuery toQuery();
303:            }
304:
305:            /**
306:             * Creates a span or query builder.
307:             *
308:             * @author kimchy
309:             */
310:            public static interface CompassQuerySpanOrBuilder {
311:
312:                /**
313:                 * Adds a span query which is or'ed with the rest of the added span
314:                 * queries.
315:                 */
316:                CompassQuerySpanOrBuilder add(CompassSpanQuery query);
317:
318:                /**
319:                 * Returns the generated span or query.
320:                 */
321:                CompassSpanQuery toQuery();
322:            }
323:
324:            /**
325:             * A more like this query builder (maps to Lucene <code>MoreLikeThis</code> feature withing
326:             * the contrib queries package).
327:             */
328:            public static interface CompassMoreLikeThisQuery extends
329:                    ToCompassQuery {
330:
331:                /**
332:                 * Sets the sub indexes that "more liket this" hits will be searched on
333:                 */
334:                CompassMoreLikeThisQuery setSubIndexes(String[] subIndexes);
335:
336:                /**
337:                 * Sets the aliases that "more liket this" hits will be searched on
338:                 */
339:                CompassMoreLikeThisQuery setAliases(String[] aliases);
340:
341:                /**
342:                 * Sets properties to the more like this query will be performed on.
343:                 */
344:                CompassMoreLikeThisQuery setProperties(String[] properties);
345:
346:                /**
347:                 * Adds a property to the more like this query will be performed on.
348:                 */
349:                CompassMoreLikeThisQuery addProperty(String property);
350:
351:                /**
352:                 * Sets the analyzer that will be used to analyze a more like this string (used when
353:                 * using {@link CompassQueryBuilder#moreLikeThis(java.io.Reader)}.
354:                 */
355:                CompassMoreLikeThisQuery setAnalyzer(String analyzer);
356:
357:                /**
358:                 * Sets whether to boost terms in query based on "score" or not.
359:                 */
360:                CompassMoreLikeThisQuery setBoost(boolean boost);
361:
362:                /**
363:                 * The maximum number of tokens to parse in each example doc field that is not stored with TermVector support
364:                 */
365:                CompassMoreLikeThisQuery setMaxNumTokensParsed(
366:                        int maxNumTokensParsed);
367:
368:                /**
369:                 * Sets the maximum number of query terms that will be included in any generated query.
370:                 */
371:                CompassMoreLikeThisQuery setMaxQueryTerms(int maxQueryTerms);
372:
373:                /**
374:                 * Sets the maximum word length above which words will be ignored. Set this to 0 for no
375:                 * maximum word length. The default is <code>0</code>.
376:                 */
377:                CompassMoreLikeThisQuery setMaxWordLen(int maxWordLen);
378:
379:                /**
380:                 * Sets the minimum word length below which words will be ignored. Set this to 0 for no
381:                 * minimum word length. The default is <code>0</code>.
382:                 */
383:                CompassMoreLikeThisQuery setMinWordLen(int minWordLen);
384:
385:                /**
386:                 * Sets the frequency at which words will be ignored which do not occur in at least this
387:                 * many resources. Defaults to 5.
388:                 */
389:                CompassMoreLikeThisQuery setMinResourceFreq(int minDocFreq);
390:
391:                /**
392:                 * Sets the frequency below which terms will be ignored in the source doc. Defaults to 2.
393:                 */
394:                CompassMoreLikeThisQuery setMinTermFreq(int minTermFreq);
395:
396:                /**
397:                 * Set the set of stopwords.
398:                 * Any word in this set is considered "uninteresting" and ignored.
399:                 * Even if your Analyzer allows stopwords, you might want to tell the MoreLikeThis code to ignore them, as
400:                 * for the purposes of document similarity it seems reasonable to assume that "a stop word is never interesting".
401:                 */
402:                CompassMoreLikeThisQuery setStopWords(String[] stopWords);
403:
404:            }
405:
406:            /**
407:             * Constructs a boolean query builder.
408:             */
409:            CompassBooleanQueryBuilder bool();
410:
411:            /**
412:             * Constructs a boolean query builder, with coord disabled.
413:             */
414:            CompassBooleanQueryBuilder bool(boolean disableCoord);
415:
416:            /**
417:             * Constructs a multi phrase query builder for the given resource property /
418:             * meta-data name.
419:             * <p/>
420:             * The name can either be the actual resource property or meta-data value,
421:             * or the path to the given resource property (alias.rProperty), or the
422:             * class property (alias.cProperty) or the path to the meta-data
423:             * (alias.cProperty.metaData)
424:             *
425:             * @param name The name of the resource property / meta-data.
426:             * @return The multi phrase query builder.
427:             */
428:            CompassMultiPhraseQueryBuilder multiPhrase(String name);
429:
430:            /**
431:             * Constructs a query string query builder.
432:             *
433:             * @param queryString The query string (i.e. +jack +london).
434:             * @return The query string query builder.
435:             */
436:            CompassQueryStringBuilder queryString(String queryString);
437:
438:            /**
439:             * Constructs a multi property query string builder, allowing to execute query strings
440:             * against several resource property names.
441:             *
442:             * @param queryString The query string (i.e. +jack +london)
443:             * @return The multi property string query builder.
444:             */
445:            CompassMultiPropertyQueryStringBuilder multiPropertyQueryString(
446:                    String queryString);
447:
448:            /**
449:             * Returns a query that <b>exactly</b> match the given alias.
450:             *
451:             * @param aliasValue The alias value to match to.
452:             * @return The generated query.
453:             */
454:            CompassQuery alias(String aliasValue);
455:
456:            /**
457:             * Returns a query that match the given alias or any extedning aliases.
458:             *
459:             * @param aliasValue The alias value to match to or any extending aliases.
460:             * @return The generated query.
461:             */
462:            CompassQuery polyAlias(String aliasValue);
463:
464:            /**
465:             * <p>Creates a query where the resource property must have the given value.
466:             * Note, that the value itself will not be analyzed, but the text that was
467:             * indexed might have been (if <code>indexed</code>). The search is case
468:             * sensative.
469:             *
470:             * <p>The name can either be the actual resource property or meta-data value,
471:             * or the path to the given resource property (alias.rProperty), or the
472:             * class property (alias.cProperty) or the path to the meta-data
473:             * (alias.cProperty.metaData)
474:             *
475:             * @param name  The resource property name
476:             * @param value The value that must match
477:             * @return The generated query
478:             */
479:            CompassQuery term(String name, Object value);
480:
481:            /**
482:             * Creates a query that match all documents.
483:             *
484:             * @return The generated query
485:             */
486:            CompassQuery matchAll();
487:
488:            /**
489:             * <p>Creates a query where the resource property is between the given values.
490:             *
491:             * <p>The name can either be the actual resource property or meta-data value,
492:             * or the path to the given resource property (alias.rProperty), or the
493:             * class property (alias.cProperty) or the path to the meta-data
494:             * (alias.cProperty.metaData)
495:             *
496:             * @param name          The resource property name
497:             * @param low           The low value limit
498:             * @param high          The high value limit
499:             * @param inclusive     If the values are inclusive or exclusive.
500:             * @param constantScore If the query will affect the score of the results. With all other range queries
501:             *                      it will default to <code>true</code>.
502:             * @return The generated query
503:             */
504:            CompassQuery between(String name, Object low, Object high,
505:                    boolean inclusive, boolean constantScore);
506:
507:            /**
508:             * <p>Creates a query where the resource property is between the given values.
509:             *
510:             * <p>The name can either be the actual resource property or meta-data value,
511:             * or the path to the given resource property (alias.rProperty), or the
512:             * class property (alias.cProperty) or the path to the meta-data
513:             * (alias.cProperty.metaData)
514:             *
515:             * @param name      The resource property name
516:             * @param low       The low value limit
517:             * @param high      The high value limit
518:             * @param inclusive If the values are inclusive or exclusive.
519:             * @return The generated query
520:             */
521:            CompassQuery between(String name, Object low, Object high,
522:                    boolean inclusive);
523:
524:            /**
525:             * <p>Creates a query where the resource property is less than (<) the given
526:             * value.
527:             *
528:             * <p>The name can either be the actual resource property or meta-data value,
529:             * or the path to the given resource property (alias.rProperty), or the
530:             * class property (alias.cProperty) or the path to the meta-data
531:             * (alias.cProperty.metaData)
532:             *
533:             * @param name  The resource property name
534:             * @param value The high limit value
535:             * @return The generated query
536:             */
537:            CompassQuery lt(String name, Object value);
538:
539:            /**
540:             * <p>Creates a query where the resource property is less or equal (<=) to the
541:             * given value.
542:             *
543:             * <p>The name can either be the actual resource property or meta-data value,
544:             * or the path to the given resource property (alias.rProperty), or the
545:             * class property (alias.cProperty) or the path to the meta-data
546:             * (alias.cProperty.metaData)
547:             *
548:             * @param name  The resource property name
549:             * @param value The high limit value
550:             * @return The generated query
551:             */
552:            CompassQuery le(String name, Object value);
553:
554:            /**
555:             * <p>Creates a query where the resource property is greater than (>) to the
556:             * given value.
557:             *
558:             * <p>The name can either be the actual resource property or meta-data value,
559:             * or the path to the given resource property (alias.rProperty), or the
560:             * class property (alias.cProperty) or the path to the meta-data
561:             * (alias.cProperty.metaData)
562:             *
563:             * @param name  The resource property name
564:             * @param value The low limit value
565:             * @return The generated query
566:             */
567:            CompassQuery gt(String name, Object value);
568:
569:            /**
570:             * <p>Creates a query where the resource property is greater or equal (>=) to
571:             * the given value.
572:             *
573:             * <p>The name can either be the actual resource property or meta-data value,
574:             * or the path to the given resource property (alias.rProperty), or the
575:             * class property (alias.cProperty) or the path to the meta-data
576:             * (alias.cProperty.metaData)
577:             *
578:             * @param name  The resource property name
579:             * @param value The low limit value
580:             * @return The generated query
581:             */
582:            CompassQuery ge(String name, Object value);
583:
584:            /**
585:             * <p>Creates a query where the resource property values starts with the given
586:             * prefix.
587:             *
588:             * <p>The name can either be the actual resource property or meta-data value,
589:             * or the path to the given resource property (alias.rProperty), or the
590:             * class property (alias.cProperty) or the path to the meta-data
591:             * (alias.cProperty.metaData)
592:             *
593:             * @param name   the resource property name
594:             * @param prefix The prefix value
595:             * @return The generated query
596:             */
597:            CompassQuery prefix(String name, String prefix);
598:
599:            /**
600:             * Creates a query where the resource property values match the given
601:             * wildcard. Supported wildcards are <code>*</code>, which matches any
602:             * character sequence (including the empty one), and <code>?</code>,
603:             * which matches any single character. Note this query can be slow, as it
604:             * needs to iterate over many terms. In order to prevent extremely slow
605:             * WildcardQueries, a Wildcard term should not start with one of the
606:             * wildcards <code>*</code> or <code>?</code>.
607:             *
608:             * @param name     The name
609:             * @param wildcard The wildcard expression
610:             * @return The generated query
611:             */
612:            CompassQuery wildcard(String name, String wildcard);
613:
614:            /**
615:             * <p>Creates a fuzzy query for the given resource property and the value. The
616:             * similiarity measurement is based on the Levenshtein (edit distance)
617:             * algorithm. The minimumSimilarity defaults to 0.5 and prefixLength
618:             * defaults to 0.
619:             *
620:             * <p>The name can either be the actual resource property or meta-data value,
621:             * or the path to the given resource property (alias.rProperty), or the
622:             * class property (alias.cProperty) or the path to the meta-data
623:             * (alias.cProperty.metaData)
624:             *
625:             * @param name  The name
626:             * @param value The value
627:             * @return The generated query
628:             */
629:            CompassQuery fuzzy(String name, String value);
630:
631:            /**
632:             * <p>Creates a fuzzy query for the given resource property and the value. The
633:             * similiarity measurement is based on the Levenshtein (edit distance)
634:             * algorithm. The prefixLength defaults to 0.
635:             *
636:             * <p>The name can either be the actual resource property or meta-data value,
637:             * or the path to the given resource property (alias.rProperty), or the
638:             * class property (alias.cProperty) or the path to the meta-data
639:             * (alias.cProperty.metaData)
640:             *
641:             * @param name              The name
642:             * @param value             The value
643:             * @param minimumSimilarity The minimum similarity, a value between 0.0 and 1.0
644:             * @return The generated query
645:             */
646:            CompassQuery fuzzy(String name, String value,
647:                    float minimumSimilarity);
648:
649:            /**
650:             * <p>Creates a fuzzy query for the given resource property and the value. The
651:             * similiarity measurement is based on the Levenshtein (edit distance)
652:             * algorithm.
653:             *
654:             * <p>The name can either be the actual resource property or meta-data value,
655:             * or the path to the given resource property (alias.rProperty), or the
656:             * class property (alias.cProperty) or the path to the meta-data
657:             * (alias.cProperty.metaData)
658:             *
659:             * @param name              The name
660:             * @param value             The value
661:             * @param minimumSimilarity The minimum similarity, a value between 0.0 and 1.0
662:             * @param prefixLength      The length of common (non-fuzzy) prefix
663:             * @return The generated query
664:             */
665:            CompassQuery fuzzy(String name, String value,
666:                    float minimumSimilarity, int prefixLength);
667:
668:            /**
669:             * <p>Creates a span query where the resource property must match the given
670:             * value.
671:             *
672:             * <p>The name can either be the actual resource property or meta-data value,
673:             * or the path to the given resource property (alias.rProperty), or the
674:             * class property (alias.cProperty) or the path to the meta-data
675:             * (alias.cProperty.metaData)
676:             *
677:             * @param name  The name
678:             * @param value The value
679:             * @return The span query
680:             */
681:            CompassSpanQuery spanEq(String name, Object value);
682:
683:            /**
684:             * <p>Creates a span query where the span occur within the first
685:             * <code>end</code> positions.
686:             *
687:             * <p>The name can either be the actual resource property or meta-data value,
688:             * or the path to the given resource property (alias.rProperty), or the
689:             * class property (alias.cProperty) or the path to the meta-data
690:             * (alias.cProperty.metaData)
691:             *
692:             * @param name  The name
693:             * @param value The value
694:             * @param end   The limit on the position from the start.
695:             * @return The span query
696:             */
697:            CompassSpanQuery spanFirst(String name, Object value, int end);
698:
699:            /**
700:             * <p>Creates a span query.
701:             *
702:             * @param end The limit on the position from the start.
703:             * @return The span query
704:             */
705:            CompassSpanQuery spanFirst(CompassSpanQuery spanQuery, int end);
706:
707:            /**
708:             * <p>Constructs a span near query builder.
709:             *
710:             * <p>The name can either be the actual resource property or meta-data value,
711:             * or the path to the given resource property (alias.rProperty), or the
712:             * class property (alias.cProperty) or the path to the meta-data
713:             * (alias.cProperty.metaData)
714:             *
715:             * @param name The name
716:             * @return The span near query builder
717:             */
718:            CompassQuerySpanNearBuilder spanNear(String name);
719:
720:            /**
721:             * <p>Creates a span query that excludes matches where one
722:             * {@link org.compass.core.CompassQuery.CompassSpanQuery} overlaps
723:             * with another.
724:             *
725:             * <p>Construct a span query matching spans from <code>include</code> which
726:             * have no overlap with spans from <code>exclude</code>.
727:             *
728:             * @param include The span query to include.
729:             * @param exclude The span query to exclude.
730:             * @return The span query
731:             */
732:            CompassSpanQuery spanNot(CompassSpanQuery include,
733:                    CompassSpanQuery exclude);
734:
735:            /**
736:             * Constructs a span or query builder.
737:             *
738:             * @return The span query builder
739:             */
740:            CompassQuerySpanOrBuilder spanOr();
741:
742:            /**
743:             * Constructs a more like this query. The id can be an object of
744:             * the class (with the id attributes set), an array of id objects, or the
745:             * actual id object. Throws an exception if the resource is not found.
746:             */
747:            CompassMoreLikeThisQuery moreLikeThis(String alias, Serializable id);
748:
749:            /**
750:             * Constructs a more like this query to find hits that are similar to
751:             * the give text represented by the reader.
752:             */
753:            CompassMoreLikeThisQuery moreLikeThis(Reader reader);
754:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.