Skip to content

Commit

Permalink
upgrade to Solr 9
Browse files Browse the repository at this point in the history
  • Loading branch information
tboeghk committed Jul 5, 2022
1 parent 59c86c6 commit 978aeb9
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 21 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<solr.version>8.11.1</solr.version>
<solr.version>9.0.0</solr.version>
</properties>

<build>
Expand Down Expand Up @@ -80,7 +80,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cool/solr/response/LuceneTemplateResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import java.util.Map;

import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.solr.core.SolrResourceLoader;
import org.thymeleaf.IEngineConfiguration;
import org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver;
import org.thymeleaf.templateresource.ITemplateResource;

public class LuceneTemplateResolver
extends AbstractConfigurableTemplateResolver {

private ResourceLoader resourceLoader;
private SolrResourceLoader resourceLoader;

public void setResourceLoader(ResourceLoader resourceLoader) {
public void setResourceLoader(SolrResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cool/solr/response/LuceneTemplateResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
import java.io.Reader;
import java.nio.charset.StandardCharsets;

import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.solr.core.SolrResourceLoader;
import org.thymeleaf.templateresource.ITemplateResource;
import org.thymeleaf.util.StringUtils;
import org.thymeleaf.util.Validate;

public class LuceneTemplateResource
implements ITemplateResource {

private final ResourceLoader resourceLoader;
private final SolrResourceLoader resourceLoader;

private final String path;

private final String characterEncoding;

public LuceneTemplateResource(ResourceLoader resourceLoader, String path, String characterEncoding) {
public LuceneTemplateResource(SolrResourceLoader resourceLoader, String path, String characterEncoding) {
this.resourceLoader = resourceLoader;
this.path = path;
this.characterEncoding = characterEncoding;
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/cool/solr/response/ThymeleafResponseWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ public void write(Writer writer, SolrQueryRequest request, SolrQueryResponse res
context.setVariable("request", request);
context.setVariable("params", request.getParams().toNamedList().asShallowMap());

// add core properties
Properties coreProperties = request.getCore().getResourceLoader().getCoreProperties();
if (coreProperties != null) {
for (Entry<Object, Object> p : coreProperties.entrySet()) {
context.setVariable(p.getKey().toString().replace('.', '_'), p.getValue());
}
}

SolrResponse rsp = new QueryResponse();
NamedList<Object> parsedResponse = BinaryResponseWriter.getParsedResponse(request, response);
rsp.setResponse(parsedResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.lucene.analysis.util.ResourceLoader;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.core.SolrResourceLoader;
import org.junit.Test;
Expand All @@ -15,9 +14,8 @@ public class LuceneTemplateResolverIT

@Test
public void testTemplateResolverConfiguration04() throws Exception {

initCore();
ResourceLoader resourceLoader = new SolrResourceLoader(testSolrHome);
initCore("solrconfig.xml", "schema.xml");
SolrResourceLoader resourceLoader = new SolrResourceLoader(testSolrHome);

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

}

}
}
19 changes: 19 additions & 0 deletions src/test/resources/solr/collection1/schema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<schema name="minimal" version="1.1">
<fieldType name="string" class="solr.StrField"/>
<dynamicField name="*" type="string" indexed="true" stored="true"/>
</schema>
46 changes: 46 additions & 0 deletions src/test/resources/solr/collection1/solrconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" ?>

<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!-- Minimal solrconfig.xml with /select, /admin and /update only -->

<config>

<dataDir>${solr.data.dir:}</dataDir>

<directoryFactory name="DirectoryFactory"
class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/>
<schemaFactory class="ClassicIndexSchemaFactory"/>

<luceneMatchVersion>${tests.luceneMatchVersion:LATEST}</luceneMatchVersion>

<updateHandler class="solr.DirectUpdateHandler2">
<commitWithin>
<softCommit>${solr.commitwithin.softcommit:true}</softCommit>
</commitWithin>

</updateHandler>
<requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="indent">true</str>
<str name="df">text</str>
</lst>

</requestHandler>
</config>

0 comments on commit 978aeb9

Please sign in to comment.