Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spatial support JTS/Geo3D #37

Closed
ChristianAdamski opened this issue May 12, 2024 · 10 comments
Closed

Spatial support JTS/Geo3D #37

ChristianAdamski opened this issue May 12, 2024 · 10 comments

Comments

@ChristianAdamski
Copy link

As written in another issue, I'm working on geolocation supoprt, specifically geometry.

POINT & LineString work, Polygon does not. Seems to require "JTS". I have understood that being the integration of another library.

Creating a collection fails.

Creating collection geometry failed with error code 400: Solr HTTP error: OK (400) { "responseHeader":{ "status":400, "QTime":484 }, "error":{ "metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","org.apache.solr.common.SolrException"], "msg":"Underlying core creation failed while creating collection: geometry", "code":400 } }

Going through the error log, this is likely caused by:

2024-05-12 08:17:34.032 ERROR (qtp693267461-162-ddev-drupal-solr-432) [c: s: r: x: t:ddev-drupal-solr-432] o.a.s.s.HttpSolrCall 500 Exception => java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/locationtech/jts/geom/CoordinateSequenceFactory
at org.apache.solr.servlet.HttpSolrCall.sendError(HttpSolrCall.java:858)
java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/locationtech/jts/geom/CoordinateSequenceFactory

which then cascades to multiple errors, finally failing as above.

1.) How do I enable "JTS"?
2.) It might be worth checking for this library being present, before trying to upload this config. Alternatively, more helpful error messages..

@ChristianAdamski
Copy link
Author

ChristianAdamski commented May 12, 2024

I downloaded jts-core-1.19.0.jar and placed it in .dev/solr/lib

Documentation now says:

Copy third party Solr modules and libraries jar files here. To load and use them within a collection, add this line to your collection's solrconfig.xml:

<lib dir="/opt/solr/modules/ddev/lib/" regex=".*\.jar" />

How would I do that?

Sorry for all the hassle. I really do not know.

@ChristianAdamski
Copy link
Author

Added the following to SolrConnectorPluginBase.php:alterConfigFiles():

$files['solrconfig.xml'] = preg_replace('/<\/config>/', '<lib dir="/opt/solr/modules/ddev/lib/" regex=".*\.jar" /></config>', $files['solrconfig.xml']);

but uploading config still fails:

2024-05-12 08:46:06.973 INFO (qtp693267461-26-ddev-drupal-solr-22) [c: s: r: x:geometry_shard1_replica_n1 t:ddev-drupal-solr-22] o.a.s.h.a.CoreAdminOperation core create command qt=/admin/cores&collection.configName=geometry_2xxqdt&newCollection=true&collection=geometry&version=2&replicaType=NRT&coreNodeName=core_node2&name=geometry_shard1_replica_n1&action=CREATE&numShards=1&shard=shard1&wt=javabin 2024-05-12 08:46:07.010 INFO (qtp693267461-26-ddev-drupal-solr-22) [c:geometry s:shard1 r:core_node2 x:geometry_shard1_replica_n1 t:ddev-drupal-solr-22] o.a.s.c.SolrResourceLoader Added 101 libs to classloader, from paths: [/opt/solr-9.6.0/modules/analysis-extras/lib, /opt/solr-9.6.0/modules/extraction/lib, /opt/solr-9.6.0/modules/langid/lib, /opt/solr-9.6.0/modules/ltr/lib, /opt/solr/modules/ddev/lib] 2024-05-12 08:46:07.041 INFO (qtp693267461-26-ddev-drupal-solr-22) [c:geometry s:shard1 r:core_node2 x:geometry_shard1_replica_n1 t:ddev-drupal-solr-22] o.a.s.c.SolrConfig Using Lucene MatchVersion: 9.10.0 2024-05-12 08:46:07.042 INFO (qtp693267461-26-ddev-drupal-solr-22) [c:geometry s:shard1 r:core_node2 x:geometry_shard1_replica_n1 t:ddev-drupal-solr-22] o.a.s.u.SolrIndexConfig IndexWriter infoStream solr logging is enabled 2024-05-12 08:46:07.056 INFO (qtp693267461-26-ddev-drupal-solr-22) [c:geometry s:shard1 r:core_node2 x:geometry_shard1_replica_n1 t:ddev-drupal-solr-22] o.a.s.s.IndexSchema Schema name=drupal-4.3.3-solr-9.x-0 2024-05-12 08:46:07.114 ERROR (qtp693267461-26-ddev-drupal-solr-22) [c: s: r: x: t:ddev-drupal-solr-22] o.a.s.s.HttpSolrCall 500 Exception => java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/locationtech/jts/geom/CoordinateSequenceFactory at org.apache.solr.servlet.HttpSolrCall.sendError(HttpSolrCall.java:858) java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/locationtech/jts/geom/CoordinateSequenceFactory

@ChristianAdamski
Copy link
Author

I do notice, with my new line added, 101 libs are loaded, without just 100...

@ChristianAdamski
Copy link
Author

Aha.

https://solr.apache.org/guide/solr/latest/query-guide/spatial-search.html

You must download it (a JAR file) and put that in a special location internal to Solr: SOLR_INSTALL/server/solr-webapp/webapp/WEB-INF/lib/. You can readily download it here: https://mvnrepository.com/artifact/org.locationtech.jts/jts-core/1.17.1. It will not work if placed in other more typical Solr lib directories, unfortunately.

@ChristianAdamski
Copy link
Author

But good news (?)

Simply altering
$jts_arguments = 'spatialContextFactory="org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory" autoIndex="true" validationRule="repairBuffer0"';

to

$jts_arguments = 'spatialContextFactory="Geo3D"';

Seems to work!

@ChristianAdamski ChristianAdamski changed the title JTS? Spatial support JTS/Geo3D May 12, 2024
@mkalkbrenner
Copy link
Collaborator

Didn't you notice that Search API Solr already provides a checkbox for JTS?

@mkalkbrenner
Copy link
Collaborator

OK, it uses the built-in Spatial4j.

So what is the request here? Switching to Geo3D might be a feature request for search_api_solr and has nothing to do with ddv-solr.
Or do you want to have jts-core added as lib to ddev-solr?

@mkalkbrenner
Copy link
Collaborator

mkalkbrenner commented May 14, 2024

@ChristianAdamski I want to do the next release of ddev-solr.
Do you need jts-core?

My concern is that most Solr hosting providers won't allow that their customers put this lib under that path.

@ChristianAdamski
Copy link
Author

ChristianAdamski commented May 14, 2024

Hey,
thanks for the effort. I'm currently just a monkey trying to figure out how the machine works. Specifically, I'm fiddling around with geo stuff when I have some spare time. I will document my findings in this issue.

I very much do not want to recommend any far reaching decissions based on that.

It might happen, as you suggested, that I will recommend a change to search_api_solr to add an option for Geo3D instead of JTS. But I'm not that far yet in my testing around. Not enough time for Open Source...

So thanks for your question, but simply do as you see fit, no need to change anything based on my work here.

@ChristianAdamski
Copy link
Author

Closing in favor of d.o Tickets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants