Skip to content

Commit 978aeb9

Browse files
committed
upgrade to Solr 9
1 parent 59c86c6 commit 978aeb9

File tree

7 files changed

+76
-21
lines changed

7 files changed

+76
-21
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5050
<maven.compiler.source>11</maven.compiler.source>
5151
<maven.compiler.target>11</maven.compiler.target>
52-
<solr.version>8.11.1</solr.version>
52+
<solr.version>9.0.0</solr.version>
5353
</properties>
5454

5555
<build>
@@ -80,7 +80,7 @@
8080
<plugin>
8181
<groupId>org.apache.maven.plugins</groupId>
8282
<artifactId>maven-assembly-plugin</artifactId>
83-
<version>3.3.0</version>
83+
<version>3.4.0</version>
8484
<configuration>
8585
<descriptorRefs>
8686
<descriptorRef>jar-with-dependencies</descriptorRef>

src/main/java/cool/solr/response/LuceneTemplateResolver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
import java.util.Map;
44

5-
import org.apache.lucene.analysis.util.ResourceLoader;
5+
import org.apache.solr.core.SolrResourceLoader;
66
import org.thymeleaf.IEngineConfiguration;
77
import org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver;
88
import org.thymeleaf.templateresource.ITemplateResource;
99

1010
public class LuceneTemplateResolver
1111
extends AbstractConfigurableTemplateResolver {
1212

13-
private ResourceLoader resourceLoader;
13+
private SolrResourceLoader resourceLoader;
1414

15-
public void setResourceLoader(ResourceLoader resourceLoader) {
15+
public void setResourceLoader(SolrResourceLoader resourceLoader) {
1616
this.resourceLoader = resourceLoader;
1717
}
1818

src/main/java/cool/solr/response/LuceneTemplateResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
import java.io.Reader;
99
import java.nio.charset.StandardCharsets;
1010

11-
import org.apache.lucene.analysis.util.ResourceLoader;
11+
import org.apache.solr.core.SolrResourceLoader;
1212
import org.thymeleaf.templateresource.ITemplateResource;
1313
import org.thymeleaf.util.StringUtils;
1414
import org.thymeleaf.util.Validate;
1515

1616
public class LuceneTemplateResource
1717
implements ITemplateResource {
1818

19-
private final ResourceLoader resourceLoader;
19+
private final SolrResourceLoader resourceLoader;
2020

2121
private final String path;
2222

2323
private final String characterEncoding;
2424

25-
public LuceneTemplateResource(ResourceLoader resourceLoader, String path, String characterEncoding) {
25+
public LuceneTemplateResource(SolrResourceLoader resourceLoader, String path, String characterEncoding) {
2626
this.resourceLoader = resourceLoader;
2727
this.path = path;
2828
this.characterEncoding = characterEncoding;

src/main/java/cool/solr/response/ThymeleafResponseWriter.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,6 @@ public void write(Writer writer, SolrQueryRequest request, SolrQueryResponse res
9898
context.setVariable("request", request);
9999
context.setVariable("params", request.getParams().toNamedList().asShallowMap());
100100

101-
// add core properties
102-
Properties coreProperties = request.getCore().getResourceLoader().getCoreProperties();
103-
if (coreProperties != null) {
104-
for (Entry<Object, Object> p : coreProperties.entrySet()) {
105-
context.setVariable(p.getKey().toString().replace('.', '_'), p.getValue());
106-
}
107-
}
108-
109101
SolrResponse rsp = new QueryResponse();
110102
NamedList<Object> parsedResponse = BinaryResponseWriter.getParsedResponse(request, response);
111103
rsp.setResponse(parsedResponse);

src/test/java/cool/solr/response/LuceneTemplateResolverIT.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6-
import org.apache.lucene.analysis.util.ResourceLoader;
76
import org.apache.solr.SolrTestCaseJ4;
87
import org.apache.solr.core.SolrResourceLoader;
98
import org.junit.Test;
@@ -15,9 +14,8 @@ public class LuceneTemplateResolverIT
1514

1615
@Test
1716
public void testTemplateResolverConfiguration04() throws Exception {
18-
19-
initCore();
20-
ResourceLoader resourceLoader = new SolrResourceLoader(testSolrHome);
17+
initCore("solrconfig.xml", "schema.xml");
18+
SolrResourceLoader resourceLoader = new SolrResourceLoader(testSolrHome);
2119

2220
TemplateEngine templateEngine = new TemplateEngine();
2321
LuceneTemplateResolver templateResolver = new LuceneTemplateResolver();
@@ -32,4 +30,4 @@ public void testTemplateResolverConfiguration04() throws Exception {
3230

3331
}
3432

35-
}
33+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<schema name="minimal" version="1.1">
17+
<fieldType name="string" class="solr.StrField"/>
18+
<dynamicField name="*" type="string" indexed="true" stored="true"/>
19+
</schema>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" ?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
-->
19+
20+
<!-- Minimal solrconfig.xml with /select, /admin and /update only -->
21+
22+
<config>
23+
24+
<dataDir>${solr.data.dir:}</dataDir>
25+
26+
<directoryFactory name="DirectoryFactory"
27+
class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/>
28+
<schemaFactory class="ClassicIndexSchemaFactory"/>
29+
30+
<luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>
31+
32+
<updateHandler class="solr.DirectUpdateHandler2">
33+
<commitWithin>
34+
<softCommit>${solr.commitwithin.softcommit:true}</softCommit>
35+
</commitWithin>
36+
37+
</updateHandler>
38+
<requestHandler name="/select" class="solr.SearchHandler">
39+
<lst name="defaults">
40+
<str name="echoParams">explicit</str>
41+
<str name="indent">true</str>
42+
<str name="df">text</str>
43+
</lst>
44+
45+
</requestHandler>
46+
</config>

0 commit comments

Comments
 (0)