Prompt Solr Query using SolrJ - solr

I am trying to structure a solr query using solrj. From my understanding of Solr-7.5.0 all libraries and dependencies for solrj should be included in my solr installation. Below is my /dist folder followed by my /dist/solrj-lib folder
Now, my query will be tied to an html post form but I want to get the solrj working first. Here is the entirety of my solrj
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.HttpSolrClient;
String queryInput = q;
SolrQuery query = new SolrQuery(queryInput);
SolrClient client = new HttpSolrClient.Builder (
"http://localhost:8983/solr/sqltest")
.build();
QueryResponse response = client.query(query);
SolrDocumentList list = response.getResults();
This will not compile because it does not recognize my classes (SolrClient, SolrQuery, etc). I am sure there are countless issues right now but Im not sure where to start.
As a side question, I was looking into other APIs that are not in compiled code. Would one of these be better used for a web application or is it safe to use solrs native solrj?

You can safely use SolrJ - in fact, if you're writing a Java application, it's the recommended way of interacting with Solr. See Using SolrJ - Building and Running SolrJ Applications for further details than what I've given below.
I've assumed you're on Windows from your screenshots - if you're on Linux or OS X, replace ; with : as the path separator below.
To include the SolrJ jar, you need to include a -classpath ".;path-to-solr-solrj-7.5.0.jar argument when running javac. This is the only jar required to compile your application.
When running it you'll have to include the jars found in the solrj-lib path. You can do this by including a class path argument to java with your files. Use java -classpath ".;path-to-solrj-lib\* to include all the jar files in the directory.

Related

Observing error while running Gatling project 'object gatling is not a member of package io'

I m seeing the following error while running Engine.scala
object gatling is not a member of package io import io.gatling.app.Gatling
Below is the code that is used
`import io.gatling.app.Gatling
import io.gatling.core.config.GatlingPropertiesBuilder
object Engine extends App {
val props = new GatlingPropertiesBuilder()
.resourcesDirectory(IDEPathHelper.mavenResourcesDirectory.toString)
.resultsDirectory(IDEPathHelper.resultsDirectory.toString)
.binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString)
Gatling.fromMap(props.build)
}`
I tried changing the Gatling version in mvn file, but no luck. could someone please help
It means the Gatling jars are not properly imported in your classpath.
No idea how to help you though as you're not describing exactly what you're doing and how you're getting this error: when running maven from the command line? when running from IntelliJ? or another IDE?
Note: if you're struggling with properly setting up a development environment for Scala, you should probably consider using Gatling with Java instead, where the set up is way more simple.

Apache Camel Rest - v3.2.0 - Multipart file upload issue

I am looking forward to achieve the multipart file upload with camel 3.2.0 version and JDK11.
I was able to successfully do the same with the older version of camel 2.x using the below code,
.post("/importFile")
.id("importFile")
.bindingMode(RestBindingMode.off)
.consumes("multipart/form-data")
.produces(IConstants.APPLICATION_JSON)
.outType(String.class)
.to("direct:importFile")
from("direct:importFile")
.unmarshal()
.mimeMultipart()
.split().attachments()
// further processing...
After upgrading the camel version from 2.x to 3.2.0, we were getting an compile time issue in the above code for ".attachments()". As a result, we replaced the from route by,
SplitAttachmentsExpression split = new SplitAttachmentsExpression();
from("direct:importFile")
.unmarshal()
.mimeMultipart()
.split(split)
// further processing...
However, after this when i debug the code i am getting null attachments.
SplitAttachmentsExpression->evaluate()->exchange.getIn(AttachmentMessage.class).hasAttachments() ==> evaluates to false.
Am i missing anything here as part of the upgrade? Has the import file functionality changed with latest version of Camel?
A quick help is highly appreciated as this was working earlier and now we are completely blocked!

Vespa Tutorial – HTTP API use-case fails to activate with IllegalArgumentException

I'm currently following the Vespa tutorials, and ran into an issue with the HTTP API use-case. Everything works fine from the mvn install package to the vespa-deploy prepare target/application.zip.
The call to vespa-deploy activate returns normally, but the application then never gets available on localhost:8080. Looking at /opt/vespa/logs/vespa/vespa.log (in the VM) one finds the following stack trace:
Container.com.yahoo.jdisc.core.StandaloneMain error Unexpected:
exception=
java.lang.IllegalArgumentException: Could not create a component with id 'com.mydomain.demo.DemoComponent'.
Tried to load class directly, since no bundle was found for spec: sample-app-http-api-searcher.
If a bundle with the same name is installed, there is a either a version mismatch or the installed bundle's version contains a qualifier string.
at com.yahoo.osgi.OsgiImpl.resolveFromClassPath(OsgiImpl.java:48)
...
This occurred using a fresh Docker image with a clean clone of the sample-apps git repository. Preparing and activating the basic sample as well as the other http example did work seamlessly.
I checked the sources and the xml files for obvious problems but don't have any clue about what is failing and where.
target/application.zip contains
application/components/http-api-using-searcher-1.0.1-deploy.jar
application/hosts.xml
application/searchdefinitions/basic.sd
application/services.xml
And the jar itself does contain a com/mydomain/demo/DemoComponent.class file (among other things).
Potentially related issue on the github tracker: https://github.com/vespa-engine/vespa/issues/3479 I'll be posting a link to this question there as well, but I still think it's worth a SO question, at least to get some action behind the vespa tag :)
The bundle id in the application's services.xml file was wrong. Please pull the application from git and try again now. See also PR: https://github.com/vespa-engine/sample-apps/pull/18
Brief explanation: The bundle id given in the bundle="<id>" declaration in services.xml must match the 'Bundle-SymbolicName' in the bundle's manifest. When the bundle has been built with the Vespa bundle-plugin, the symbolic name is by default the same as the project's artifactId. Hence, in most cases you just have to verify that the bundle id matches the artifactId.

gwt-dev.jar conflicts with icu jar on war/lib classpath when using GAE

Ok I have to rewrite my question after further investigation.
I run into below problem in my GWT/GAE project :
java.lang.RuntimeException: Class com.google.appengine.tools.development.agent.runtime.Runtime$21 can not access a member of class com.ibm.icu.text.CollatorServiceShim with modifiers ""
at com.ibm.icu.text.Collator.getShim(Collator.java:456)
at com.ibm.icu.text.Collator.getInstance(Collator.java:478)
at com.google.visualization.datasource.datatable.value.TextValue$1.<init>(TextValue.java:126)
at com.google.visualization.datasource.datatable.value.TextValue.getTextLocalizedComparator(TextValue.java:125)
at com.google.visualization.datasource.datatable.value.Value$1.<init>(Value.java:141)
at com.google.visualization.datasource.datatable.value.Value.getLocalizedComparator(Value.java:140)
at com.google.visualization.datasource.query.engine.TableRowComparator.<init>(TableRowComparator.java:66)
at com.google.visualization.datasource.query.engine.QueryEngine.performSort(QueryEngine.java:234)
at com.google.visualization.datasource.query.engine.QueryEngine.executeQuery(QueryEngine.java:128)
at com.google.visualization.datasource.DataSourceHelper.applyQuery(DataSourceHelper.java:410)
at com.klawt.server.resources.chart.InvoicesChartServerResource.retrieve(InvoicesChartServerResource.java:129)
Some more investigation revealed that gwt-dev.jar contains a copy of the icu library :
public abstract class com.ibm.icu.text.Collator implements
java.util.Comparator, com.ibm.icu.util.Freezable
is part of gwt-dev.jar
My project has a dependency on icu4j 4.0.1 (for the Google Visualization Datasource library). But GAE SDK insists on using the version included in gwt-dev.jar;
I guess there must a way to setup my development environment so this kinda works, it did before.
I have tried moving GWT SDK to the bottom in the 'Order and export' tab of my build path and the icu jar to the top, but no luck.
Switching from OpenJDK to Oracle JDK fixes it !! It is not the first time I ran into issues with OpenJDK !

How to configure custom solr instance to use Morfologik?

I have a custom solr instance running in tomcat. I followed tomcat deployment tutorial in SolrWiki. I want to index my data which are in Polish language and I want to use Morfologik. So i followed http://solr.pl/en/2012/04/02/solr-4-0-and-polish-language-analysis/. I've created lib folder in SOLR_HOME, added all libraries to this folder, changed schema to use solr.MorfologikFilterFactory but i still get such error:
'collection1: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] fieldType „text_pl”: Plugin init failure for [schema.xml] analyzer/filter: Error loading class "solr.MorfologikFilterFactory"'
I assume there is a problem with paths. I hope so, because if not it might by quite hard to solve...
Anybody can help me? Thanks!
you can add lib path to the solrconfig.xml - see the xml supplied with example.
are you using the SolrCloud mode or standalone?

Resources