Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

JTS Topology Suite with Solr

JTS Topology Suite with Solr

New Contributor

Hi,

 

I need to index polygons in a collection (CDH 5.7.0 with Solr 4.10.3), so I followed this documentation Spatial Search :

Spoiler
Solr supports polygons via JTS Topology Suite, which does not come with Solr. It's a JAR file that you need to put on Solr's classpath (but not via the standard solrconfig.xml mechanisms). If you intend to use those shapes, set this attribute to org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory . (note: prior to Solr 6, the "org.locationtech.spatial4j" part was "com.spatial4j.core").

This is the fieldtype I'm trying to use in schema.xml :

<fieldType name="geometry" class="solr.SpatialRecursivePrefixTreeFieldType" distErrPct="0.025" spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory" maxDistErr="0.000009" units="degrees"/>

And I copied JTS 1.4 jar files in /var/lib/solr/tomcat-deployment/webapps/solr/WEB-INF/lib/ but when I reload or recreate my collection I have this error :

Aug 18, 2016 3:52:40 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.ClassNotFoundException: com.vividsolutions.jts.geom.CoordinateSequenceFactory
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
	at java.lang.Class.getConstructor0(Class.java:3075)
	at java.lang.Class.newInstance(Class.java:412)
	at com.spatial4j.core.context.SpatialContextFactory.makeSpatialContext(SpatialContextFactory.java:96)
	at org.apache.solr.schema.AbstractSpatialFieldType.init(AbstractSpatialFieldType.java:129)
	at org.apache.solr.schema.AbstractSpatialPrefixTreeFieldType.init(AbstractSpatialPrefixTreeFieldType.java:43)
	at org.apache.solr.schema.SpatialRecursivePrefixTreeFieldType.init(SpatialRecursivePrefixTreeFieldType.java:37)
	at org.apache.solr.schema.FieldType.setArgs(FieldType.java:166)
	at org.apache.solr.schema.FieldTypePluginLoader.init(FieldTypePluginLoader.java:141)
	at org.apache.solr.schema.FieldTypePluginLoader.init(FieldTypePluginLoader.java:43)
	at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:190)
	at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:486)
	at org.apache.solr.schema.IndexSchema.<init>(IndexSchema.java:166)
	at org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55)
	at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69)
	at org.apache.solr.core.ConfigSetService.createIndexSchema(ConfigSetService.java:92)
	at org.apache.solr.core.ConfigSetService.getConfig(ConfigSetService.java:63)
	at org.apache.solr.core.CoreContainer.create(CoreContainer.java:496)
	at org.apache.solr.core.CoreContainer.create(CoreContainer.java:473)
	at org.apache.solr.handler.admin.CoreAdminHandler.handleCreateAction(CoreAdminHandler.java:576)
	at org.apache.solr.handler.admin.CoreAdminHandler.handleRequestInternal(CoreAdminHandler.java:200)
	at org.apache.solr.handler.admin.CoreAdminHandler.handleRequestBody(CoreAdminHandler.java:189)
	at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
	at org.apache.solr.servlet.SolrDispatchFilter.handleAdminRequest(SolrDispatchFilter.java:808)
	at org.apache.solr.servlet.SolrDispatchFilter.httpSolrCall(SolrDispatchFilter.java:275)
	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:221)
	at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:216)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.solr.servlet.SolrHadoopAuthenticationFilter$2.doFilter(SolrHadoopAuthenticationFilter.java:394)
	at org.apache.hadoop.security.authentication.server.AuthenticationFilter.doFilter(AuthenticationFilter.java:622)
	at org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticationFilter.doFilter(DelegationTokenAuthenticationFilter.java:291)
	at org.apache.hadoop.security.authentication.server.AuthenticationFilter.doFilter(AuthenticationFilter.java:574)
	at org.apache.solr.servlet.SolrHadoopAuthenticationFilter.doFilter(SolrHadoopAuthenticationFilter.java:399)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.solr.servlet.HostnameFilter.doFilter(HostnameFilter.java:86)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:745)

If I change the fieldtype by removing the spatialContextFactory, it works fine but I can't use polygons properly.

 

Any idea how to solve this would be appreciated.

 

Thanks,

Florian

 

1 REPLY 1
Highlighted

Re: JTS Topology Suite with Solr

New Contributor

Hi, 

 

I don't think this is the best solution, however it should work:

 

1) cd /opt/cloudera/parcels/CDH-5.16.1-1.cdh5.16.1.p0.3/lib/solr/webapps/solr/WEB-INF/lib
2) wget https://repo1.maven.org/maven2/com/vividsolutions/jts-core/1.14.0/jts-core-1.14.0.jar

 

Then just restart Solr Service from Cloudera Manager.

 

Oscar

 

Don't have an account?
Coming from Hortonworks? Activate your account here