1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.search.solr.internal; |
21 |
|
|
22 |
|
import java.io.IOException; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import javax.inject.Inject; |
26 |
|
|
27 |
|
import org.apache.solr.client.solrj.SolrClient; |
28 |
|
import org.apache.solr.client.solrj.SolrServerException; |
29 |
|
import org.apache.solr.client.solrj.StreamingResponseCallback; |
30 |
|
import org.apache.solr.client.solrj.response.QueryResponse; |
31 |
|
import org.apache.solr.common.SolrInputDocument; |
32 |
|
import org.apache.solr.common.params.SolrParams; |
33 |
|
import org.slf4j.Logger; |
34 |
|
import org.xwiki.search.solr.internal.api.SolrInstance; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@see |
40 |
|
@version |
41 |
|
@since |
42 |
|
|
|
|
| 41.4% |
Uncovered Elements: 17 (29) |
Complexity: 10 |
Complexity Density: 0.53 |
|
43 |
|
public abstract class AbstractSolrInstance implements SolrInstance |
44 |
|
{ |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
protected SolrClient server; |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@Inject |
54 |
|
protected Logger logger; |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
56 |
4031 |
@Override... |
57 |
|
public void add(SolrInputDocument solrDocument) throws SolrServerException, IOException |
58 |
|
{ |
59 |
4031 |
this.logger.debug("Add Solr document [{}] to index", solrDocument); |
60 |
|
|
61 |
4031 |
this.server.add(solrDocument); |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
64 |
0 |
@Override... |
65 |
|
public void add(List<SolrInputDocument> solrDocuments) throws SolrServerException, IOException |
66 |
|
{ |
67 |
0 |
this.logger.debug("Add Solr documents [{}] to index", solrDocuments); |
68 |
|
|
69 |
0 |
this.server.add(solrDocuments); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
72 |
433 |
@Override... |
73 |
|
public void delete(String id) throws SolrServerException, IOException |
74 |
|
{ |
75 |
433 |
this.logger.debug("Delete Solr document [{}] from index", id); |
76 |
|
|
77 |
433 |
this.server.deleteById(id); |
78 |
|
} |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
80 |
0 |
@Override... |
81 |
|
public void delete(List<String> ids) throws SolrServerException, IOException |
82 |
|
{ |
83 |
0 |
this.logger.debug("Delete Solr documents [{}] from index", ids); |
84 |
|
|
85 |
0 |
this.server.deleteById(ids); |
86 |
|
} |
87 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
88 |
0 |
@Override... |
89 |
|
public void deleteByQuery(String query) throws SolrServerException, IOException |
90 |
|
{ |
91 |
0 |
this.logger.debug("Delete Solr documents from index based on query [{}]", query); |
92 |
|
|
93 |
0 |
this.server.deleteByQuery(query); |
94 |
|
} |
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
96 |
328 |
@Override... |
97 |
|
public void commit() throws SolrServerException, IOException |
98 |
|
{ |
99 |
328 |
this.logger.debug("Commit changes to Solr"); |
100 |
|
|
101 |
328 |
this.server.commit(); |
102 |
|
} |
103 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
104 |
0 |
@Override... |
105 |
|
public void rollback() throws SolrServerException, IOException |
106 |
|
{ |
107 |
0 |
this.logger.debug("Rollback changes to Solr"); |
108 |
|
|
109 |
0 |
this.server.rollback(); |
110 |
|
} |
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
112 |
1016 |
@Override... |
113 |
|
public QueryResponse query(SolrParams solrParams) throws SolrServerException, IOException |
114 |
|
{ |
115 |
1016 |
this.logger.debug("Execute Solr query [{}]", solrParams); |
116 |
|
|
117 |
1016 |
return this.server.query(solrParams); |
118 |
|
} |
119 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
120 |
0 |
@Override... |
121 |
|
public QueryResponse queryAndStreamResponse(SolrParams params, StreamingResponseCallback callback) |
122 |
|
throws SolrServerException, IOException |
123 |
|
{ |
124 |
0 |
this.logger.debug("Execute Solr query and stream response [{}]", params); |
125 |
|
|
126 |
0 |
return this.server.queryAndStreamResponse(params, callback); |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
@return |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
134 |
0 |
protected SolrClient getServer()... |
135 |
|
{ |
136 |
0 |
return this.server; |
137 |
|
} |
138 |
|
} |