Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
SolrInstance | 44 | 0 | - | 0 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.search.solr.internal.api; | |
21 | ||
22 | import java.io.IOException; | |
23 | import java.util.List; | |
24 | ||
25 | import org.apache.solr.client.solrj.SolrServerException; | |
26 | import org.apache.solr.client.solrj.StreamingResponseCallback; | |
27 | import org.apache.solr.client.solrj.response.QueryResponse; | |
28 | import org.apache.solr.common.SolrInputDocument; | |
29 | import org.apache.solr.common.params.SolrParams; | |
30 | import org.xwiki.component.annotation.Role; | |
31 | import org.xwiki.component.phase.Initializable; | |
32 | ||
33 | /** | |
34 | * Component in charge of communicating with the actual Solr server. This is direct access and consistency is not | |
35 | * enforced at this level. | |
36 | * <p> | |
37 | * Note: This is also useful for testing since it can be replaced with a mock, this way allowing us to test just our | |
38 | * code. | |
39 | * | |
40 | * @version $Id: 33f4ecba8ec32fa5aff63220f6856ce419194f34 $ | |
41 | * @since 4.3M2 | |
42 | */ | |
43 | @Role | |
44 | public interface SolrInstance extends Initializable | |
45 | { | |
46 | /** | |
47 | * Add a {@link SolrInputDocument} to the Solr index. | |
48 | * <p> | |
49 | * Note: Does not apply until you call {@link #commit()}. | |
50 | * | |
51 | * @param solrDocument the document. | |
52 | * @throws SolrServerException if problems occur. | |
53 | * @throws IOException if problems occur. | |
54 | */ | |
55 | void add(SolrInputDocument solrDocument) throws SolrServerException, IOException; | |
56 | ||
57 | /** | |
58 | * Add a list of {@link SolrInputDocument} to the Solr index. This is a batch operation. | |
59 | * <p> | |
60 | * Note: Does not apply until you call {@link #commit()}. | |
61 | * | |
62 | * @param solrDocuments the documents. | |
63 | * @throws SolrServerException if problems occur. | |
64 | * @throws IOException if problems occur. | |
65 | */ | |
66 | void add(List<SolrInputDocument> solrDocuments) throws SolrServerException, IOException; | |
67 | ||
68 | /** | |
69 | * Delete a single entry from the Solr index. | |
70 | * <p> | |
71 | * Note: Does not apply until you call {@link #commit()}. | |
72 | * | |
73 | * @param id the ID of the entry. | |
74 | * @throws SolrServerException if problems occur. | |
75 | * @throws IOException if problems occur. | |
76 | */ | |
77 | void delete(String id) throws SolrServerException, IOException; | |
78 | ||
79 | /** | |
80 | * Delete a list of entries from the Solr index. This is a batch operation. | |
81 | * <p> | |
82 | * Note: Does not apply until you call {@link #commit()}. | |
83 | * | |
84 | * @param ids the list of entry IDs | |
85 | * @throws SolrServerException if problems occur. | |
86 | * @throws IOException if problems occur. | |
87 | */ | |
88 | void delete(List<String> ids) throws SolrServerException, IOException; | |
89 | ||
90 | /** | |
91 | * Delete entries from the index based on the result of the given query. | |
92 | * <p> | |
93 | * Note: Does not apply until you call {@link #commit()}. | |
94 | * | |
95 | * @param query the Solr query. | |
96 | * @throws SolrServerException if problems occur. | |
97 | * @throws IOException if problems occur. | |
98 | */ | |
99 | void deleteByQuery(String query) throws SolrServerException, IOException; | |
100 | ||
101 | /** | |
102 | * Commit the recent (uncommitted) changes to the Solr server. | |
103 | * | |
104 | * @throws SolrServerException if problems occur. | |
105 | * @throws IOException if problems occur. | |
106 | */ | |
107 | void commit() throws SolrServerException, IOException; | |
108 | ||
109 | /** | |
110 | * Cancel the local uncommitted changes that were not yet pushed to the Solr server. | |
111 | * | |
112 | * @throws SolrServerException if problems occur. | |
113 | * @throws IOException if problems occur. | |
114 | */ | |
115 | void rollback() throws SolrServerException, IOException; | |
116 | ||
117 | /** | |
118 | * Query the server's index using the Solr Query API. | |
119 | * | |
120 | * @param solrParams Solr Query API. | |
121 | * @return the query result. | |
122 | * @throws SolrServerException if problems occur. | |
123 | * @throws IOException if there is an error on the server | |
124 | */ | |
125 | QueryResponse query(SolrParams solrParams) throws SolrServerException, IOException; | |
126 | ||
127 | /** | |
128 | * Query solr, and stream the results. Unlike the standard query, this will send events for each Document rather | |
129 | * then add them to the {@link QueryResponse}. | |
130 | * <p> | |
131 | * Although this function returns a {@link QueryResponse} it should be used with care since it excludes anything | |
132 | * that was passed to callback. Also note that future version may pass even more info to the callback and may not | |
133 | * return the results in the {@link QueryResponse}. | |
134 | * | |
135 | * @param params query parameters | |
136 | * @param callback the object to notify | |
137 | * @return the query result | |
138 | * @throws SolrServerException if problems occur | |
139 | * @throws IOException if problems occur | |
140 | */ | |
141 | QueryResponse queryAndStreamResponse(SolrParams params, StreamingResponseCallback callback) | |
142 | throws SolrServerException, IOException; | |
143 | } |