3131@ Profile ("!" + ConfigurationProfiles .MOCK_SEARCH )
3232public class IndexServiceImpl implements IndexService {
3333
34+ private static final String ANALYZER = "analyzer" ;
35+ private static final String SEARCH_ANALYZER = "search_analyzer" ;
36+
37+ private static final String ITEM_ID = "itemid" ;
38+ private static final String UUID = "uuid" ;
39+ private static final String LANGUAGE = "language" ;
40+ private static final String TYPE = "type" ;
41+ private static final String TITLE = "title" ;
42+ private static final String DESCRIPTION = "description" ;
43+ private static final String COPYRIGHTED = "copyrighted" ;
44+ private static final String PUBLISHED = "published" ;
45+ private static final String SECTION = "section" ;
46+ private static final String CODES = "codes" ;
47+ private static final String FAMILY = "family" ;
48+ private static final String CLASSIFICATION_ID = "classificationId" ;
49+ private static final String LEGAL_BASE = "legalBase" ;
50+ private static final String PUBLICATIONS = "publications" ;
51+ private static final String DERIVED_FROM = "derivedFrom" ;
52+
3453 private static final Logger log = LoggerFactory .getLogger (IndexServiceImpl .class );
3554
3655 @ Value ("${klass.env.search.elasticsearch.index:klass}" )
@@ -55,6 +74,7 @@ private IndexCoordinates getIndexCoordinates() {
5574
5675 @ PostConstruct
5776 private void createIndexWithStemmingAnalyzer () {
77+
5878 try {
5979 var indexOps = elasticsearchOperations .indexOps (getIndexCoordinates ());
6080
@@ -63,11 +83,12 @@ private void createIndexWithStemmingAnalyzer() {
6383 return ;
6484 }
6585
86+
6687 Map <String , Object > settings =
6788 Map .of (
6889 "analysis" ,
6990 Map .of (
70- "analyzer" ,
91+ ANALYZER ,
7192 Map .of (
7293 OpenSearchConfig .NORWEGIAN_STEMMER_ANALYZER ,
7394 Map .of (
@@ -88,35 +109,34 @@ private void createIndexWithStemmingAnalyzer() {
88109 Map .of (
89110 "properties" ,
90111 Map .of (
91- "title" ,
112+ TITLE ,
92113 Map .of (
93114 "type" , "text" ,
94- "analyzer" ,
115+ ANALYZER ,
95116 OpenSearchConfig
96117 .NORWEGIAN_STEMMER_ANALYZER ,
97- "search_analyzer" ,
118+ SEARCH_ANALYZER ,
98119 OpenSearchConfig
99120 .NORWEGIAN_STEMMER_ANALYZER ),
100- "description" ,
121+ DESCRIPTION ,
101122 Map .of (
102- "type" , "text" ,
103- "analyzer" ,
123+ "type" , "text" , ANALYZER ,
104124 OpenSearchConfig
105125 .NORWEGIAN_STEMMER_ANALYZER ,
106- "search_analyzer" ,
126+ SEARCH_ANALYZER ,
107127 OpenSearchConfig
108128 .NORWEGIAN_STEMMER_ANALYZER ),
109- "codes" ,
129+ CODES ,
110130 Map .of (
111131 "type" , "text" ,
112- "analyzer" ,
132+ ANALYZER ,
113133 OpenSearchConfig
114134 .NORWEGIAN_STEMMER_ANALYZER ,
115- "search_analyzer " ,
135+ "" ,
116136 OpenSearchConfig
117137 .NORWEGIAN_STEMMER_ANALYZER ),
118- "family" , Map .of ("type" , "keyword" ),
119- "section" , Map .of ("type" , "keyword" )));
138+ FAMILY , Map .of ("type" , "keyword" ),
139+ SECTION , Map .of ("type" , "keyword" )));
120140
121141 boolean created = indexOps .create (settings );
122142 if (created ) {
@@ -212,21 +232,6 @@ private void updateElasticsearch(SoftDeletable entity, Map<String, Object> doc)
212232
213233 /** Inner class to handle document mapping from domain entities to search documents */
214234 private static class DocumentMapper {
215- private static final String ITEM_ID = "itemid" ;
216- private static final String UUID = "uuid" ;
217- private static final String LANGUAGE = "language" ;
218- private static final String TYPE = "type" ;
219- private static final String TITLE = "title" ;
220- private static final String DESCRIPTION = "description" ;
221- private static final String COPYRIGHTED = "copyrighted" ;
222- private static final String PUBLISHED = "published" ;
223- private static final String SECTION = "section" ;
224- private static final String CODES = "codes" ;
225- private static final String FAMILY = "family" ;
226- private static final String CLASSIFICATION_ID = "classificationId" ;
227- private static final String LEGAL_BASE = "legalBase" ;
228- private static final String PUBLICATIONS = "publications" ;
229- private static final String DERIVED_FROM = "derivedFrom" ;
230235
231236 public Map <String , Object > mapClassificationSeries (
232237 ClassificationSeries classification , Language language ) {
0 commit comments