15
15
*/
16
16
package edu .unc .lib .boxc .search .solr .config ;
17
17
18
+ import edu .unc .lib .boxc .search .api .SearchFieldKey ;
19
+ import org .apache .solr .client .solrj .SolrClient ;
20
+ import org .apache .solr .client .solrj .impl .HttpSolrClient ;
21
+ import org .slf4j .Logger ;
22
+ import org .slf4j .LoggerFactory ;
23
+
18
24
import java .util .ArrayList ;
19
25
import java .util .HashMap ;
20
26
import java .util .List ;
27
+ import java .util .Map ;
21
28
import java .util .Properties ;
22
29
import java .util .regex .Matcher ;
23
30
import java .util .regex .Pattern ;
24
31
25
- import org .apache .solr .client .solrj .SolrClient ;
26
- import org .apache .solr .client .solrj .impl .HttpSolrClient ;
27
- import org .slf4j .Logger ;
28
- import org .slf4j .LoggerFactory ;
29
-
30
32
/**
31
33
* Utility class which stores Solr index addressing and instantiation settings from a properties file.
32
34
*
@@ -43,10 +45,13 @@ public class SolrSettings extends AbstractSettings {
43
45
private int maxConnections ;
44
46
private int maxRetries ;
45
47
// Mapping of field keys to internal solr field names
46
- private HashMap <String , String > fieldNames ;
48
+ private Map <String , String > fieldNames ;
47
49
// Reverse of fieldName, for translating from the internal solr field name to the general field identification key
48
- private HashMap <String , String > fieldNameToKey ;
49
- private String [] requiredFields ;
50
+ private Map <String , String > fieldNameToKey ;
51
+ private String [] requiredFields = new String [] {
52
+ SearchFieldKey .ADMIN_GROUP .getSolrField (), SearchFieldKey .ID .getSolrField (),
53
+ SearchFieldKey .RESOURCE_TYPE .getSolrField (), SearchFieldKey .ROLE_GROUP .getSolrField (),
54
+ SearchFieldKey .ROLLUP_ID .getSolrField (), SearchFieldKey .TITLE .getSolrField () };
50
55
51
56
public SolrSettings () {
52
57
fieldNames = new HashMap <>();
@@ -62,7 +67,6 @@ public void setProperties(Properties properties) {
62
67
LOG .debug ("Setting properties." );
63
68
this .setPath (properties .getProperty ("solr.path" , "" ));
64
69
this .setCore (properties .getProperty ("solr.core" , "" ));
65
- this .setRequiredFields (properties .getProperty ("solr.requiredFields" , "" ));
66
70
this .setSocketTimeout (Integer .parseInt (properties .getProperty ("solr.socketTimeout" , "1000" )));
67
71
this .setConnectionTimeout (Integer .parseInt (properties .getProperty ("solr.connectionTimeout" , "100" )));
68
72
this .setDefaultMaxConnectionsPerHost (Integer .parseInt (properties .getProperty (
@@ -175,10 +179,6 @@ public String[] getRequiredFields() {
175
179
return requiredFields ;
176
180
}
177
181
178
- public void setRequiredFields (String requiredFields ) {
179
- this .requiredFields = requiredFields .split ("," );
180
- }
181
-
182
182
public int getSocketTimeout () {
183
183
return socketTimeout ;
184
184
}
@@ -232,38 +232,15 @@ public String toStringStatic() {
232
232
}
233
233
234
234
/**
235
- * Returns the field identification key for the internal solr field name given
235
+ * Returns the dynamic field identification key for the internal solr field name given
236
236
*
237
237
* @param name
238
238
* @return
239
239
*/
240
- public String getFieldKey (String name ) {
240
+ public String getDynamicFieldKey (String name ) {
241
241
return fieldNameToKey .get (name );
242
242
}
243
243
244
- public HashMap <String , String > getFieldNameToKey () {
245
- return this .fieldNameToKey ;
246
- }
247
-
248
- /**
249
- * Returns the internal solr field name for the field identified by key
250
- *
251
- * @param key
252
- * @return
253
- */
254
- public String getFieldName (String key ) {
255
- return fieldNames .get (key );
256
- }
257
-
258
- public HashMap <String , String > getFieldNames () {
259
- return fieldNames ;
260
- }
261
-
262
- public void setFieldNames (HashMap <String , String > fieldNames ) {
263
- this .fieldNames = fieldNames ;
264
- fieldNameToKey = getInvertedHashMap (fieldNames );
265
- }
266
-
267
244
public int getMaxRetries () {
268
245
return maxRetries ;
269
246
}
0 commit comments