How to install spatial4j into solr4 - solr

Im exploring Solr4 and Polygons/linestrings.
There is some info on it here but not a howto/installation guide for a basic user like me.
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
As far as I understand, you need to install the spatial4j code into solr. (Im a hack at best).
https://github.com/spatial4j/spatial4j/tree/master/src/main/java
Does one know where I upload this code to, inside the solr4 installation? Keep in mind im using the /example/solr/collection1 directory.
"Due to a combination of things, JTS can't simply be referenced by a "" entry in solrconfig.xml; it needs to be in WEB-INF/lib in Solr's war file, basicall" Does anyone know what that means in terms of an installation instruction? Im after some guidance of what goes where. I use start.jar to start solr on my apache server.
After that I understand that I simply need to add a field type and field () to the schema and as far as that goes it should be installed.
Im trying to send it polygon and linestring queries to find all documents within a polygon or within a radius of a line.

Solr includes Spatial4j already; what it doesn't have is JTS, which is a java library (.jar file). Download JTS from https://sourceforge.net/projects/jts-topo-suite/ (the .jar is within the .zip distro). WEB-INF/lib is a java webapp reference within a WAR file. example/webapps/solr.war is where that is. A .war file is really a zip, and can either be in it's '.war' file form or be uncompressed in a plain directory layout. So if you rename the '.war' to '.zip' in OSX it's trivial to double-click it in order to expand it. But then rename the resulting directory to 'solr.war', and put aside the original war file to some other place as you won't be using it for now. Take the JTS jar and put it in solr.war/WEB-INF/lib/. When you start Solr, it'll have access to JTS. If it doesn't have access due to whatever reason, you'll get a ClassNotFoundException pertaining to a JTS related Java class.

Related

Solr to Application Insights

How can I configure Solr logs to get sent to Azure Application Insights?
I see can use a Log4J appender.
https://learn.microsoft.com/en-us/azure/application-insights/app-insights-java-trace-logs
Solr is an open source project, and I don't compile it myself, I just use the distribution.
How can I drop in Application Insights/Log4J appender, without recompiling having installed the SDK?
I just want to configure the logs to get sent to application insghts, for effectively a 3rd party application.
And configure the instrumentation key.
I'm normally a C# dev, but familiar with Log4Net. So appologies if this is simple in Java Log4J. Not been able to find a post for this scenario so posting here.
Using Solr 6.6.
It takes a lot less configuration than you'd expect, and most of the info is hidden away in the link that you've already got: https://learn.microsoft.com/en-gb/azure/azure-monitor/app/java-trace-logs
First, go download the jar files from https://github.com/Microsoft/ApplicationInsights-Java/releases. You'll want applicationinsights-logging-log4j1_2-2.3.0 and applicationinsights-core-2.3.0. Put these in the server/lib folder and Solr will load them automatically for you.
Next you''ll need to add a new appender for app insights into your log4j.properties file
# Appinsights
log4j.appender.aiAppender=com.microsoft.applicationinsights.log4j.v1_2.ApplicationInsightsAppender
log4j.appender.aiAppender.layout=org.apache.log4j.EnhancedPatternLayout
log4j.appender.aiAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p (%t) [%X{collection} %X{shard} %X{replica} %X{core}] %c{1.} %m%n
You also need to add this aiAppender to the log4j.rootLogger list in the same file (it'll probably look something like this: log4j.rootLogger=INFO, file, CONSOLE, aiAppender)
Finally, you need an ApplicationInsights.xml file, which you can get an example of from here https://learn.microsoft.com/en-gb/azure/azure-monitor/app/java-get-started#2-add-the-application-insights-sdk-for-java-to-your-project
Drop this in the server/resources folder, set your instrumentation key and you're good to go!

solr index java source files as text

I want to upload lots of source files (say, java) to solr to allow indexed search on them.
They should be posted as plain text files.
No special parsing is required.
When trying to upload one java file I get "Unknown Source" related error.
java.lang.NoClassDefFoundError: com/uwyn/jhighlight/renderer/XhtmlRendererFactory
When I rename the file adding .txt in the end, it is uploaded successfully.
I have thousands of files to upload on a daily basis and need to keep original names.
How do I tell solr to treat all files in the directory as .txt?
Advanced thanks!
For googlers, concerning the Solr error:
java.lang.NoClassDefFoundError: com/uwyn/jhighlight/renderer/XhtmlRendererFactory
You can correct this by adding the jar "jhighlight-1.0.jar" in Solr. To do so:
Download the old solr 4.9. In recent version, jhighlight is not present.
Extract solr-4.9.0\contrib\extraction\lib\jhighlight-1.0.jar
Copy jhighlight-1.0.jar to the solr installation under solr/server/lib/ext/
Restart the server.
You can achieve the same by integrating solr with tika.
Apache will help you to extract the text of the source files.
It has a source code parser which supports c,c++ and Java.
Here is the link which will give you more details.
https://googleweblight.com/?lite_url=https://tika.apache.org/1.12/formats.html&lc=en-IN&s=1&m=972&host=www.google.co.in&ts=1461564865&sig=APY536wBFFAcFH7yUyvhh2TFslPz6LeClA

Does Google Cloud Debugger require that source files be placed in a specific locations in the repository?

I'm trying to setup Cloud Debugging for a Python App Engine module without success. See this question for the specific issue I am having.
I am wondering if the reason for my issue is the locations of the source files in my repository.
My source files are (for various reasons) in rather idiosyncratic locations and I have a "build" step that copies the files into into a staging directory where everything is laid out as app engine expects. It also generates some files (including the app.yaml) based on configuration settings.
I then run appcfg.py update from this staging directory.
Given all this moving around of files, I am wondering how the Cloud Debugger can identify which source file in the module I uploaded corresponds to which file in the repository. Is it designed to look in a specific locations (which will explain my problem), or is it somehow more robust than that?
I don't think the issue is related to location of source files in the repository.
The Python Cloud Debugger loops through all the loaded modules and tries to find the best match. The actual location of the module only matters if there are multiple modules with the same name. In this case, the debugger will try to find the best match given the relative path of the files in the repository. You can see the implementation here.

Easiest way to deploy customized Lucene QueryParser onto Solr core

I have developed a customization to Lucene QueryParser by changing the QueryParser.jj grammar. One way to deploy this onto Solr is to revamp the Solr war file by compiling new lucene core.
On the other hand, a new query parser on Solr level can be deployed as a binary dependency (jar) into Solr core's lib directory, which is very convenient.
Is there a similar way to deploy my customization?
Could I deploy my lucene-core binary dependency into core's lib directory or somewhere else but the Solr war file?
UPD: The comments to the answer contain the thought process behind my implementation.
UPD2: I have written a blog post on my findings: http://dmitrykan.blogspot.fi/2014/03/implementing-own-luceneqparserplugin.html
As I understand you can write your own parser (with a new name), place this jar into the lib folder and add the corresponding <queryParser> to solrconfig.xml. See an example of a query parser, implemented by John Berryman #JnBrymn.

Unknown query type 'spatial' How do I see what plugins Solr has loaded?

I'm trying to setup the Spatial Search Plugin for Apache Solr with my install. It appears from the logging at startup that it found the JAR file, however when I try to run a query with just "{!spatial}" it complains it doesn't know that query type.
I'm assuming it hasn't actually picked up the plugin or something else is wrong. How can I confirm that Solr knows about that JAR?
As an aside, I only stuck the JAR in the solr/lib directory, so I'm not sure it there are additional things I need to do.

Resources