Search code examples
javasolrsolrj

Java Application to Query Solr


I have indexed a catalog of documents in Solr. I do not need to add/update, I'm purely looking to create a basic GUI application where the user defines the query by means of a text box and receives results, all within a single Java application.

I know that SolrJ seems to be the right pick, but where do I start? It's all local, I just want to set up a prototype interface.


Solution

  • Talking about solrj, I assume you are pointing to embedded Solr Server.

    You need to create an instance of the Solr Server like one of the following -

    SolrServer server = new HttpSolrServer("http://HOST:8983/solr/");
    

    OR

    SolrServer server = new EmbeddedSolrServer();
    

    Then you can create an instance of SolrQuery and add the query i.e. what the user has entered in the textbox. Query the server and the server would return a list of SolrDocuments to you.

    To understand SolrQuery have a look here