Source Code Cross Referenced for Searcher.java in  » Net » lucene-connector » org » apache » lucene » search » 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 » Net » lucene connector » org.apache.lucene.search 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.lucene.search;
002:
003:        /**
004:         * Licensed to the Apache Software Foundation (ASF) under one or more
005:         * contributor license agreements.  See the NOTICE file distributed with
006:         * this work for additional information regarding copyright ownership.
007:         * The ASF licenses this file to You under the Apache License, Version 2.0
008:         * (the "License"); you may not use this file except in compliance with
009:         * the License.  You may obtain a copy of the License at
010:         *
011:         *     http://www.apache.org/licenses/LICENSE-2.0
012:         *
013:         * Unless required by applicable law or agreed to in writing, software
014:         * distributed under the License is distributed on an "AS IS" BASIS,
015:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016:         * See the License for the specific language governing permissions and
017:         * limitations under the License.
018:         */
019:
020:        import java.io.IOException;
021:
022:        import org.apache.lucene.index.CorruptIndexException;
023:        import org.apache.lucene.index.Term;
024:        import org.apache.lucene.document.Document;
025:
026:        /** An abstract base class for search implementations.
027:         * Implements the main search methods.
028:         * 
029:         * <p>Note that you can only access Hits from a Searcher as long as it is
030:         * not yet closed, otherwise an IOException will be thrown. 
031:         */
032:        public abstract class Searcher implements  Searchable {
033:
034:            /** Returns the documents matching <code>query</code>. 
035:             * @throws BooleanQuery.TooManyClauses
036:             */
037:            public final Hits search(Query query) throws IOException {
038:                return search(query, (Filter) null);
039:            }
040:
041:            /** Returns the documents matching <code>query</code> and
042:             * <code>filter</code>.
043:             * @throws BooleanQuery.TooManyClauses
044:             */
045:            public Hits search(Query query, Filter filter) throws IOException {
046:                return new Hits(this , query, filter);
047:            }
048:
049:            /** Returns documents matching <code>query</code> sorted by
050:             * <code>sort</code>.
051:             * @throws BooleanQuery.TooManyClauses
052:             */
053:            public Hits search(Query query, Sort sort) throws IOException {
054:                return new Hits(this , query, null, sort);
055:            }
056:
057:            /** Returns documents matching <code>query</code> and <code>filter</code>,
058:             * sorted by <code>sort</code>.
059:             * @throws BooleanQuery.TooManyClauses
060:             */
061:            public Hits search(Query query, Filter filter, Sort sort)
062:                    throws IOException {
063:                return new Hits(this , query, filter, sort);
064:            }
065:
066:            /** Expert: Low-level search implementation with arbitrary sorting.  Finds
067:             * the top <code>n</code> hits for <code>query</code>, applying
068:             * <code>filter</code> if non-null, and sorting the hits by the criteria in
069:             * <code>sort</code>.
070:             *
071:             * <p>Applications should usually call {@link
072:             * Searcher#search(Query,Filter,Sort)} instead.
073:             * @throws BooleanQuery.TooManyClauses
074:             */
075:            public TopFieldDocs search(Query query, Filter filter, int n,
076:                    Sort sort) throws IOException {
077:                return search(createWeight(query), filter, n, sort);
078:            }
079:
080:            /** Lower-level search API.
081:             *
082:             * <p>{@link HitCollector#collect(int,float)} is called for every non-zero
083:             * scoring document.
084:             *
085:             * <p>Applications should only use this if they need <i>all</i> of the
086:             * matching documents.  The high-level search API ({@link
087:             * Searcher#search(Query)}) is usually more efficient, as it skips
088:             * non-high-scoring hits.
089:             * <p>Note: The <code>score</code> passed to this method is a raw score.
090:             * In other words, the score will not necessarily be a float whose value is
091:             * between 0 and 1.
092:             * @throws BooleanQuery.TooManyClauses
093:             */
094:            public void search(Query query, HitCollector results)
095:                    throws IOException {
096:                search(query, (Filter) null, results);
097:            }
098:
099:            /** Lower-level search API.
100:             *
101:             * <p>{@link HitCollector#collect(int,float)} is called for every non-zero
102:             * scoring document.
103:             * <br>HitCollector-based access to remote indexes is discouraged.
104:             *
105:             * <p>Applications should only use this if they need <i>all</i> of the
106:             * matching documents.  The high-level search API ({@link
107:             * Searcher#search(Query)}) is usually more efficient, as it skips
108:             * non-high-scoring hits.
109:             *
110:             * @param query to match documents
111:             * @param filter if non-null, a bitset used to eliminate some documents
112:             * @param results to receive hits
113:             * @throws BooleanQuery.TooManyClauses
114:             */
115:            public void search(Query query, Filter filter, HitCollector results)
116:                    throws IOException {
117:                search(createWeight(query), filter, results);
118:            }
119:
120:            /** Expert: Low-level search implementation.  Finds the top <code>n</code>
121:             * hits for <code>query</code>, applying <code>filter</code> if non-null.
122:             *
123:             * <p>Called by {@link Hits}.
124:             *
125:             * <p>Applications should usually call {@link Searcher#search(Query)} or
126:             * {@link Searcher#search(Query,Filter)} instead.
127:             * @throws BooleanQuery.TooManyClauses
128:             */
129:            public TopDocs search(Query query, Filter filter, int n)
130:                    throws IOException {
131:                return search(createWeight(query), filter, n);
132:            }
133:
134:            /** Returns an Explanation that describes how <code>doc</code> scored against
135:             * <code>query</code>.
136:             *
137:             * <p>This is intended to be used in developing Similarity implementations,
138:             * and, for good performance, should not be displayed with every hit.
139:             * Computing an explanation is as expensive as executing the query over the
140:             * entire index.
141:             */
142:            public Explanation explain(Query query, int doc) throws IOException {
143:                return explain(createWeight(query), doc);
144:            }
145:
146:            /** The Similarity implementation used by this searcher. */
147:            private Similarity similarity = Similarity.getDefault();
148:
149:            /** Expert: Set the Similarity implementation used by this Searcher.
150:             *
151:             * @see Similarity#setDefault(Similarity)
152:             */
153:            public void setSimilarity(Similarity similarity) {
154:                this .similarity = similarity;
155:            }
156:
157:            /** Expert: Return the Similarity implementation used by this Searcher.
158:             *
159:             * <p>This defaults to the current value of {@link Similarity#getDefault()}.
160:             */
161:            public Similarity getSimilarity() {
162:                return this .similarity;
163:            }
164:
165:            /**
166:             * creates a weight for <code>query</code>
167:             * @return new weight
168:             */
169:            protected Weight createWeight(Query query) throws IOException {
170:                return query.weight(this );
171:            }
172:
173:            // inherit javadoc
174:            public int[] docFreqs(Term[] terms) throws IOException {
175:                int[] result = new int[terms.length];
176:                for (int i = 0; i < terms.length; i++) {
177:                    result[i] = docFreq(terms[i]);
178:                }
179:                return result;
180:            }
181:
182:            /* The following abstract methods were added as a workaround for GCJ bug #15411.
183:             * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15411
184:             */
185:            abstract public void search(Weight weight, Filter filter,
186:                    HitCollector results) throws IOException;
187:
188:            abstract public void close() throws IOException;
189:
190:            abstract public int docFreq(Term term) throws IOException;
191:
192:            abstract public int maxDoc() throws IOException;
193:
194:            abstract public TopDocs search(Weight weight, Filter filter, int n)
195:                    throws IOException;
196:
197:            abstract public Document doc(int i) throws CorruptIndexException,
198:                    IOException;
199:
200:            abstract public Query rewrite(Query query) throws IOException;
201:
202:            abstract public Explanation explain(Weight weight, int doc)
203:                    throws IOException;
204:
205:            abstract public TopFieldDocs search(Weight weight, Filter filter,
206:                    int n, Sort sort) throws IOException;
207:            /* End patch for GCJ bug #15411. */
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.