Source Code Cross Referenced for DefaultCompassQueryBuilder.java in  » Search-Engine » compass-2.0 » org » compass » core » impl » 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.impl 
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.impl;
018:
019:        import java.io.Reader;
020:        import java.io.Serializable;
021:
022:        import org.compass.core.CompassException;
023:        import org.compass.core.CompassQuery;
024:        import org.compass.core.CompassQuery.CompassSpanQuery;
025:        import org.compass.core.CompassQueryBuilder;
026:        import org.compass.core.Resource;
027:        import org.compass.core.engine.SearchEngineQuery;
028:        import org.compass.core.engine.SearchEngineQuery.SearchEngineSpanQuery;
029:        import org.compass.core.engine.SearchEngineQueryBuilder;
030:        import org.compass.core.engine.SearchEngineQueryBuilder.SearchEngineBooleanQueryBuilder;
031:        import org.compass.core.engine.SearchEngineQueryBuilder.SearchEngineMultiPhraseQueryBuilder;
032:        import org.compass.core.engine.SearchEngineQueryBuilder.SearchEngineMultiPropertyQueryStringBuilder;
033:        import org.compass.core.engine.SearchEngineQueryBuilder.SearchEngineQuerySpanNearBuilder;
034:        import org.compass.core.engine.SearchEngineQueryBuilder.SearchEngineQuerySpanOrBuilder;
035:        import org.compass.core.engine.SearchEngineQueryBuilder.SearchEngineQueryStringBuilder;
036:        import org.compass.core.mapping.ResourcePropertyLookup;
037:        import org.compass.core.spi.InternalCompassSession;
038:
039:        /**
040:         * @author kimchy
041:         */
042:        public class DefaultCompassQueryBuilder implements  CompassQueryBuilder {
043:
044:            public static class DefaultCompassBooleanQueryBuilder implements 
045:                    CompassBooleanQueryBuilder {
046:
047:                private SearchEngineBooleanQueryBuilder queryBuilder;
048:
049:                private InternalCompassSession session;
050:
051:                public DefaultCompassBooleanQueryBuilder(
052:                        SearchEngineBooleanQueryBuilder queryBuilder,
053:                        InternalCompassSession session) {
054:                    this .queryBuilder = queryBuilder;
055:                    this .session = session;
056:                }
057:
058:                public CompassBooleanQueryBuilder addMust(CompassQuery query) {
059:                    queryBuilder.addMust(((DefaultCompassQuery) query)
060:                            .getSearchEngineQuery());
061:                    return this ;
062:                }
063:
064:                public CompassBooleanQueryBuilder addMustNot(CompassQuery query) {
065:                    queryBuilder.addMustNot(((DefaultCompassQuery) query)
066:                            .getSearchEngineQuery());
067:                    return this ;
068:                }
069:
070:                public CompassBooleanQueryBuilder addShould(CompassQuery query) {
071:                    queryBuilder.addShould(((DefaultCompassQuery) query)
072:                            .getSearchEngineQuery());
073:                    return this ;
074:                }
075:
076:                public CompassQuery toQuery() {
077:                    SearchEngineQuery query = queryBuilder.toQuery();
078:                    return new DefaultCompassQuery(query, session);
079:                }
080:
081:            }
082:
083:            public static class DefaultCompassMultiPhraseQueryBuilder implements 
084:                    CompassMultiPhraseQueryBuilder {
085:
086:                private SearchEngineMultiPhraseQueryBuilder queryBuilder;
087:
088:                private InternalCompassSession session;
089:
090:                private ResourcePropertyLookup lookup;
091:
092:                public DefaultCompassMultiPhraseQueryBuilder(
093:                        SearchEngineMultiPhraseQueryBuilder queryBuilder,
094:                        InternalCompassSession session,
095:                        ResourcePropertyLookup lookup) {
096:                    this .queryBuilder = queryBuilder;
097:                    this .session = session;
098:                    this .lookup = lookup;
099:                }
100:
101:                public CompassMultiPhraseQueryBuilder setSlop(int slop) {
102:                    queryBuilder.setSlop(slop);
103:                    return this ;
104:                }
105:
106:                public CompassMultiPhraseQueryBuilder add(Object value) {
107:                    queryBuilder.add(lookup.getValue(value));
108:                    return this ;
109:                }
110:
111:                public CompassMultiPhraseQueryBuilder add(Object value,
112:                        int position) {
113:                    queryBuilder.add(lookup.getValue(value), position);
114:                    return this ;
115:                }
116:
117:                public CompassMultiPhraseQueryBuilder add(Object[] values) {
118:                    String[] strValues = new String[values.length];
119:                    for (int i = 0; i < values.length; i++) {
120:                        strValues[i] = lookup.getValue(values[i]);
121:                    }
122:                    queryBuilder.add(strValues);
123:                    return this ;
124:                }
125:
126:                public CompassMultiPhraseQueryBuilder add(Object[] values,
127:                        int position) {
128:                    String[] strValues = new String[values.length];
129:                    for (int i = 0; i < values.length; i++) {
130:                        strValues[i] = lookup.getValue(values[i]);
131:                    }
132:                    queryBuilder.add(strValues, position);
133:                    return this ;
134:                }
135:
136:                public CompassQuery toQuery() {
137:                    SearchEngineQuery query = queryBuilder.toQuery();
138:                    return new DefaultCompassQuery(query, session);
139:                }
140:            }
141:
142:            public static class DefaultCompassQueryStringBuilder implements 
143:                    CompassQueryStringBuilder {
144:
145:                private SearchEngineQueryStringBuilder queryBuilder;
146:
147:                private InternalCompassSession session;
148:
149:                public DefaultCompassQueryStringBuilder(
150:                        SearchEngineQueryStringBuilder queryBuilder,
151:                        InternalCompassSession session) {
152:                    this .queryBuilder = queryBuilder;
153:                    this .session = session;
154:                }
155:
156:                public CompassQueryStringBuilder setAnalyzer(String analyzer)
157:                        throws CompassException {
158:                    queryBuilder.setAnalyzer(analyzer);
159:                    return this ;
160:                }
161:
162:                public CompassQueryStringBuilder setAnalyzerByAlias(String alias)
163:                        throws CompassException {
164:                    queryBuilder.setAnalyzerByAlias(alias);
165:                    return this ;
166:                }
167:
168:                public CompassQueryStringBuilder setQueryParser(
169:                        String queryParser) throws CompassException {
170:                    queryBuilder.setQueryParser(queryParser);
171:                    return this ;
172:                }
173:
174:                public CompassQueryStringBuilder useSpellCheck()
175:                        throws CompassException {
176:                    queryBuilder.useSpellCheck();
177:                    return this ;
178:                }
179:
180:                public CompassQueryStringBuilder setDefaultSearchProperty(
181:                        String defaultSearchProperty) {
182:                    queryBuilder
183:                            .setDefaultSearchProperty(defaultSearchProperty);
184:                    return this ;
185:                }
186:
187:                public CompassQueryStringBuilder useAndDefaultOperator() {
188:                    queryBuilder.useAndDefaultOperator();
189:                    return this ;
190:                }
191:
192:                public CompassQueryStringBuilder useOrDefaultOperator() {
193:                    queryBuilder.useOrDefaultOperator();
194:                    return this ;
195:                }
196:
197:                public CompassQueryStringBuilder forceAnalyzer() {
198:                    queryBuilder.forceAnalyzer();
199:                    return this ;
200:                }
201:
202:                public CompassQuery toQuery() {
203:                    SearchEngineQuery query = queryBuilder.toQuery();
204:                    return new DefaultCompassQuery(query, session);
205:                }
206:
207:            }
208:
209:            public static class DefaultCompassMultiPropertyQueryStringBuilder
210:                    implements  CompassMultiPropertyQueryStringBuilder {
211:
212:                private SearchEngineMultiPropertyQueryStringBuilder queryBuilder;
213:
214:                private InternalCompassSession session;
215:
216:                public DefaultCompassMultiPropertyQueryStringBuilder(
217:                        SearchEngineMultiPropertyQueryStringBuilder queryBuilder,
218:                        InternalCompassSession session) {
219:                    this .queryBuilder = queryBuilder;
220:                    this .session = session;
221:                }
222:
223:                public CompassMultiPropertyQueryStringBuilder setAnalyzer(
224:                        String analyzer) throws CompassException {
225:                    queryBuilder.setAnalyzer(analyzer);
226:                    return this ;
227:                }
228:
229:                public CompassMultiPropertyQueryStringBuilder setAnalyzerByAlias(
230:                        String alias) throws CompassException {
231:                    queryBuilder.setAnalyzerByAlias(alias);
232:                    return this ;
233:                }
234:
235:                public CompassMultiPropertyQueryStringBuilder setQueryParser(
236:                        String queryParser) throws CompassException {
237:                    queryBuilder.setQueryParser(queryParser);
238:                    return this ;
239:                }
240:
241:                public CompassMultiPropertyQueryStringBuilder useSpellCheck() {
242:                    queryBuilder.useSpellCheck();
243:                    return this ;
244:                }
245:
246:                public CompassMultiPropertyQueryStringBuilder add(String name) {
247:                    queryBuilder.add(session.getMapping()
248:                            .getResourcePropertyLookup(name).getPath());
249:                    return this ;
250:                }
251:
252:                public CompassMultiPropertyQueryStringBuilder useAndDefaultOperator() {
253:                    queryBuilder.useAndDefaultOperator();
254:                    return this ;
255:                }
256:
257:                public CompassMultiPropertyQueryStringBuilder forceAnalyzer() {
258:                    queryBuilder.forceAnalyzer();
259:                    return this ;
260:                }
261:
262:                public CompassQuery toQuery() {
263:                    SearchEngineQuery query = queryBuilder.toQuery();
264:                    return new DefaultCompassQuery(query, session);
265:                }
266:            }
267:
268:            public static class DefaultCompassQuerySpanNearBuilder implements 
269:                    CompassQuerySpanNearBuilder {
270:
271:                private SearchEngineQuerySpanNearBuilder queryBuilder;
272:
273:                private InternalCompassSession session;
274:
275:                private ResourcePropertyLookup lookup;
276:
277:                public DefaultCompassQuerySpanNearBuilder(
278:                        SearchEngineQuerySpanNearBuilder queryBuilder,
279:                        InternalCompassSession session,
280:                        ResourcePropertyLookup lookup) {
281:                    this .queryBuilder = queryBuilder;
282:                    this .session = session;
283:                    this .lookup = lookup;
284:                }
285:
286:                public CompassQuerySpanNearBuilder setSlop(int slop) {
287:                    queryBuilder.setSlop(slop);
288:                    return this ;
289:                }
290:
291:                public CompassQuerySpanNearBuilder setInOrder(boolean inOrder) {
292:                    queryBuilder.setInOrder(inOrder);
293:                    return this ;
294:                }
295:
296:                public CompassQuerySpanNearBuilder add(Object value) {
297:                    queryBuilder.add(lookup.getValue(value));
298:                    return this ;
299:                }
300:
301:                public CompassQuerySpanNearBuilder add(CompassSpanQuery query) {
302:                    queryBuilder
303:                            .add(((DefaultCompassQuery.DefaultCompassSpanQuey) query)
304:                                    .getSearchEngineSpanQuery());
305:                    return this ;
306:                }
307:
308:                public CompassSpanQuery toQuery() {
309:                    SearchEngineSpanQuery query = queryBuilder.toQuery();
310:                    return new DefaultCompassQuery.DefaultCompassSpanQuey(
311:                            query, session);
312:                }
313:            }
314:
315:            public static class DefaultCompassQuerySpanOrBuilder implements 
316:                    CompassQuerySpanOrBuilder {
317:
318:                private SearchEngineQuerySpanOrBuilder queryBuilder;
319:
320:                private InternalCompassSession session;
321:
322:                public DefaultCompassQuerySpanOrBuilder(
323:                        SearchEngineQuerySpanOrBuilder queryBuilder,
324:                        InternalCompassSession session) {
325:                    this .queryBuilder = queryBuilder;
326:                    this .session = session;
327:                }
328:
329:                public CompassQuerySpanOrBuilder add(CompassSpanQuery query) {
330:                    queryBuilder
331:                            .add(((DefaultCompassQuery.DefaultCompassSpanQuey) query)
332:                                    .getSearchEngineSpanQuery());
333:                    return this ;
334:                }
335:
336:                public CompassSpanQuery toQuery() {
337:                    SearchEngineSpanQuery query = queryBuilder.toQuery();
338:                    return new DefaultCompassQuery.DefaultCompassSpanQuey(
339:                            query, session);
340:                }
341:            }
342:
343:            public static class DefaultCompassMoreLikeThisQuery implements 
344:                    CompassMoreLikeThisQuery {
345:
346:                private SearchEngineQueryBuilder.SearchEngineMoreLikeThisQueryBuilder queryBuilder;
347:
348:                private InternalCompassSession session;
349:
350:                public DefaultCompassMoreLikeThisQuery(
351:                        SearchEngineQueryBuilder.SearchEngineMoreLikeThisQueryBuilder queryBuilder,
352:                        InternalCompassSession session) {
353:                    this .queryBuilder = queryBuilder;
354:                    this .session = session;
355:                }
356:
357:                public CompassMoreLikeThisQuery setSubIndexes(
358:                        String[] subIndexes) {
359:                    queryBuilder.setSubIndexes(subIndexes);
360:                    return this ;
361:                }
362:
363:                public CompassMoreLikeThisQuery setAliases(String[] aliases) {
364:                    queryBuilder.setAliases(aliases);
365:                    return this ;
366:                }
367:
368:                public CompassMoreLikeThisQuery setProperties(
369:                        String[] properties) {
370:                    if (properties == null) {
371:                        queryBuilder.setProperties(properties);
372:                    } else {
373:                        String[] updatedProperties = new String[properties.length];
374:                        for (int i = 0; i < properties.length; i++) {
375:                            ResourcePropertyLookup lookup = session
376:                                    .getMapping().getResourcePropertyLookup(
377:                                            properties[i]);
378:                            updatedProperties[i] = lookup.getPath();
379:                        }
380:                        queryBuilder.setProperties(updatedProperties);
381:                    }
382:                    return this ;
383:                }
384:
385:                public CompassMoreLikeThisQuery addProperty(String property) {
386:                    ResourcePropertyLookup lookup = session.getMapping()
387:                            .getResourcePropertyLookup(property);
388:                    queryBuilder.addProperty(lookup.getPath());
389:                    return this ;
390:                }
391:
392:                public CompassMoreLikeThisQuery setAnalyzer(String analyzer) {
393:                    queryBuilder.setAnalyzer(analyzer);
394:                    return this ;
395:                }
396:
397:                public CompassMoreLikeThisQuery setBoost(boolean boost) {
398:                    queryBuilder.setBoost(boost);
399:                    return this ;
400:                }
401:
402:                public CompassMoreLikeThisQuery setMaxNumTokensParsed(
403:                        int maxNumTokensParsed) {
404:                    queryBuilder.setMaxNumTokensParsed(maxNumTokensParsed);
405:                    return this ;
406:                }
407:
408:                public CompassMoreLikeThisQuery setMaxQueryTerms(
409:                        int maxQueryTerms) {
410:                    queryBuilder.setMaxQueryTerms(maxQueryTerms);
411:                    return this ;
412:                }
413:
414:                public CompassMoreLikeThisQuery setMaxWordLen(int maxWordLen) {
415:                    queryBuilder.setMaxWordLen(maxWordLen);
416:                    return this ;
417:                }
418:
419:                public CompassMoreLikeThisQuery setMinWordLen(int minWordLen) {
420:                    queryBuilder.setMinWordLen(minWordLen);
421:                    return this ;
422:                }
423:
424:                public CompassMoreLikeThisQuery setMinResourceFreq(
425:                        int minDocFreq) {
426:                    queryBuilder.setMinResourceFreq(minDocFreq);
427:                    return this ;
428:                }
429:
430:                public CompassMoreLikeThisQuery setMinTermFreq(int minTermFreq) {
431:                    queryBuilder.setMinTermFreq(minTermFreq);
432:                    return this ;
433:                }
434:
435:                public CompassMoreLikeThisQuery setStopWords(String[] stopWords) {
436:                    queryBuilder.setStopWords(stopWords);
437:                    return this ;
438:                }
439:
440:                public CompassQuery toQuery() {
441:                    SearchEngineQuery query = queryBuilder.toQuery();
442:                    return new DefaultCompassQuery(query, session);
443:                }
444:            }
445:
446:            private SearchEngineQueryBuilder queryBuilder;
447:
448:            private InternalCompassSession session;
449:
450:            public DefaultCompassQueryBuilder(
451:                    SearchEngineQueryBuilder queryBuilder,
452:                    InternalCompassSession session) {
453:                this .queryBuilder = queryBuilder;
454:                this .session = session;
455:            }
456:
457:            public CompassBooleanQueryBuilder bool() {
458:                return new DefaultCompassBooleanQueryBuilder(queryBuilder
459:                        .bool(), session);
460:            }
461:
462:            public CompassBooleanQueryBuilder bool(boolean disableCoord) {
463:                return new DefaultCompassBooleanQueryBuilder(queryBuilder
464:                        .bool(disableCoord), session);
465:            }
466:
467:            public CompassMultiPhraseQueryBuilder multiPhrase(String name) {
468:                ResourcePropertyLookup lookup = session.getMapping()
469:                        .getResourcePropertyLookup(name);
470:                return new DefaultCompassMultiPhraseQueryBuilder(queryBuilder
471:                        .multiPhrase(lookup.getPath()), session, lookup);
472:            }
473:
474:            public CompassQueryStringBuilder queryString(String queryString) {
475:                return new DefaultCompassQueryStringBuilder(queryBuilder
476:                        .queryString(queryString), session);
477:            }
478:
479:            public CompassMultiPropertyQueryStringBuilder multiPropertyQueryString(
480:                    String queryString) {
481:                return new DefaultCompassMultiPropertyQueryStringBuilder(
482:                        queryBuilder.multiPropertyQueryString(queryString),
483:                        session);
484:            }
485:
486:            public CompassQuery alias(String aliasValue) {
487:                if (!session.getCompass().getMapping().hasRootMappingByAlias(
488:                        aliasValue)) {
489:                    throw new CompassException("Alias [" + aliasValue
490:                            + "] not found in Compass mappings definitions");
491:                }
492:                String aliasProperty = session.getCompass()
493:                        .getSearchEngineFactory().getAliasProperty();
494:                SearchEngineQuery query = queryBuilder.term(aliasProperty,
495:                        aliasValue);
496:                return new DefaultCompassQuery(query, session);
497:            }
498:
499:            public CompassQuery polyAlias(String aliasValue) {
500:                return bool().addShould(
501:                        term(session.getCompass().getSearchEngineFactory()
502:                                .getAliasProperty(), aliasValue)).addShould(
503:                        term(session.getCompass().getSearchEngineFactory()
504:                                .getExtendedAliasProperty(), aliasValue))
505:                        .toQuery();
506:            }
507:
508:            public CompassQuery term(String name, Object value) {
509:                ResourcePropertyLookup lookup = session.getMapping()
510:                        .getResourcePropertyLookup(name);
511:                SearchEngineQuery query = queryBuilder.term(lookup.getPath(),
512:                        lookup.getValue(value));
513:                return new DefaultCompassQuery(query, session);
514:            }
515:
516:            public CompassQuery matchAll() {
517:                SearchEngineQuery query = queryBuilder.matchAll();
518:                return new DefaultCompassQuery(query, session);
519:            }
520:
521:            public CompassQuery between(String name, Object low, Object high,
522:                    boolean inclusive, boolean constantScore) {
523:                ResourcePropertyLookup lookup = session.getMapping()
524:                        .getResourcePropertyLookup(name);
525:                SearchEngineQuery query = queryBuilder.between(
526:                        lookup.getPath(), lookup.getValue(low), lookup
527:                                .getValue(high), inclusive, constantScore);
528:                return new DefaultCompassQuery(query, session);
529:            }
530:
531:            public CompassQuery between(String name, Object low, Object high,
532:                    boolean inclusive) {
533:                ResourcePropertyLookup lookup = session.getMapping()
534:                        .getResourcePropertyLookup(name);
535:                SearchEngineQuery query = queryBuilder.between(
536:                        lookup.getPath(), lookup.getValue(low), lookup
537:                                .getValue(high), inclusive);
538:                return new DefaultCompassQuery(query, session);
539:            }
540:
541:            public CompassQuery lt(String name, Object value) {
542:                ResourcePropertyLookup lookup = session.getMapping()
543:                        .getResourcePropertyLookup(name);
544:                SearchEngineQuery query = queryBuilder.lt(lookup.getPath(),
545:                        lookup.getValue(value));
546:                return new DefaultCompassQuery(query, session);
547:            }
548:
549:            public CompassQuery le(String name, Object value) {
550:                ResourcePropertyLookup lookup = session.getMapping()
551:                        .getResourcePropertyLookup(name);
552:                SearchEngineQuery query = queryBuilder.le(lookup.getPath(),
553:                        lookup.getValue(value));
554:                return new DefaultCompassQuery(query, session);
555:            }
556:
557:            public CompassQuery gt(String name, Object value) {
558:                ResourcePropertyLookup lookup = session.getMapping()
559:                        .getResourcePropertyLookup(name);
560:                SearchEngineQuery query = queryBuilder.gt(lookup.getPath(),
561:                        lookup.getValue(value));
562:                return new DefaultCompassQuery(query, session);
563:            }
564:
565:            public CompassQuery ge(String name, Object value) {
566:                ResourcePropertyLookup lookup = session.getMapping()
567:                        .getResourcePropertyLookup(name);
568:                SearchEngineQuery query = queryBuilder.ge(lookup.getPath(),
569:                        lookup.getValue(value));
570:                return new DefaultCompassQuery(query, session);
571:            }
572:
573:            public CompassQuery prefix(String name, String prefix) {
574:                ResourcePropertyLookup lookup = session.getMapping()
575:                        .getResourcePropertyLookup(name);
576:                SearchEngineQuery query = queryBuilder.prefix(lookup.getPath(),
577:                        prefix);
578:                return new DefaultCompassQuery(query, session);
579:            }
580:
581:            public CompassQuery wildcard(String name, String wildcard) {
582:                ResourcePropertyLookup lookup = session.getMapping()
583:                        .getResourcePropertyLookup(name);
584:                SearchEngineQuery query = queryBuilder.wildcard(lookup
585:                        .getPath(), wildcard);
586:                return new DefaultCompassQuery(query, session);
587:            }
588:
589:            public CompassQuery fuzzy(String name, String value,
590:                    float minimumSimilarity) {
591:                ResourcePropertyLookup lookup = session.getMapping()
592:                        .getResourcePropertyLookup(name);
593:                SearchEngineQuery query = queryBuilder.fuzzy(lookup.getPath(),
594:                        value, minimumSimilarity);
595:                return new DefaultCompassQuery(query, session);
596:            }
597:
598:            public CompassQuery fuzzy(String name, String value,
599:                    float minimumSimilarity, int prefixLength) {
600:                ResourcePropertyLookup lookup = session.getMapping()
601:                        .getResourcePropertyLookup(name);
602:                SearchEngineQuery query = queryBuilder.fuzzy(lookup.getPath(),
603:                        value, minimumSimilarity, prefixLength);
604:                return new DefaultCompassQuery(query, session);
605:            }
606:
607:            public CompassQuery fuzzy(String name, String value) {
608:                ResourcePropertyLookup lookup = session.getMapping()
609:                        .getResourcePropertyLookup(name);
610:                SearchEngineQuery query = queryBuilder.fuzzy(lookup.getPath(),
611:                        value);
612:                return new DefaultCompassQuery(query, session);
613:            }
614:
615:            public CompassSpanQuery spanEq(String name, Object value) {
616:                ResourcePropertyLookup lookup = session.getMapping()
617:                        .getResourcePropertyLookup(name);
618:                SearchEngineSpanQuery query = queryBuilder.spanEq(lookup
619:                        .getPath(), lookup.getValue(value));
620:                return new DefaultCompassQuery.DefaultCompassSpanQuey(query,
621:                        session);
622:            }
623:
624:            public CompassSpanQuery spanFirst(String name, Object value, int end) {
625:                ResourcePropertyLookup lookup = session.getMapping()
626:                        .getResourcePropertyLookup(name);
627:                SearchEngineSpanQuery query = queryBuilder.spanFirst(lookup
628:                        .getPath(), lookup.getValue(value), end);
629:                return new DefaultCompassQuery.DefaultCompassSpanQuey(query,
630:                        session);
631:            }
632:
633:            public CompassSpanQuery spanFirst(CompassSpanQuery spanQuery,
634:                    int end) {
635:                SearchEngineSpanQuery query = queryBuilder
636:                        .spanFirst(
637:                                ((DefaultCompassQuery.DefaultCompassSpanQuey) spanQuery)
638:                                        .getSearchEngineSpanQuery(), end);
639:                return new DefaultCompassQuery.DefaultCompassSpanQuey(query,
640:                        session);
641:            }
642:
643:            public CompassQuerySpanNearBuilder spanNear(String name) {
644:                ResourcePropertyLookup lookup = session.getMapping()
645:                        .getResourcePropertyLookup(name);
646:                return new DefaultCompassQuerySpanNearBuilder(queryBuilder
647:                        .spanNear(lookup.getPath()), session, lookup);
648:            }
649:
650:            public CompassSpanQuery spanNot(CompassSpanQuery include,
651:                    CompassSpanQuery exclude) {
652:                SearchEngineSpanQuery query = queryBuilder.spanNot(
653:                        ((DefaultCompassQuery.DefaultCompassSpanQuey) include)
654:                                .getSearchEngineSpanQuery(),
655:                        ((DefaultCompassQuery.DefaultCompassSpanQuey) exclude)
656:                                .getSearchEngineSpanQuery());
657:                return new DefaultCompassQuery.DefaultCompassSpanQuey(query,
658:                        session);
659:            }
660:
661:            public CompassQuerySpanOrBuilder spanOr() {
662:                return new DefaultCompassQuerySpanOrBuilder(queryBuilder
663:                        .spanOr(), session);
664:            }
665:
666:            public CompassMoreLikeThisQuery moreLikeThis(String alias,
667:                    Serializable id) {
668:                Resource idResource = session.getMarshallingStrategy()
669:                        .marshallIds(alias, id);
670:                SearchEngineQueryBuilder.SearchEngineMoreLikeThisQueryBuilder mltQueryBuilder = queryBuilder
671:                        .moreLikeThis(idResource);
672:                return new DefaultCompassMoreLikeThisQuery(mltQueryBuilder,
673:                        session);
674:            }
675:
676:            public CompassMoreLikeThisQuery moreLikeThis(Reader reader) {
677:                SearchEngineQueryBuilder.SearchEngineMoreLikeThisQueryBuilder mltQueryBuilder = queryBuilder
678:                        .moreLikeThis(reader);
679:                return new DefaultCompassMoreLikeThisQuery(mltQueryBuilder,
680:                        session);
681:            }
682:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.