Search code examples
postgresqlsolrdataimporthandler

Solr PostgreSQL Basic Configuration


I'm struggling to get a basic connection going between PostgreSQL (primary data source) and Solr. There are a number of posts on it I have tried to follow. Here is what I have done (in linux), attempting to modify the dih example to my needs with the Data Import Handler.

from https://jdbc.postgresql.org/download.html I download postgresql-9.4.1212.jre6.jar and place it in solr-6.4.0/dist.

I edit the solrconfig.xml at solr-6.4.0/example/example-DIH/solr/solr/conf in the lib include area as follows:

<lib dir="${solr.install.dir:../../../..}/dist/" regex="postgresql-.*\.jar" />

and in the request area as follows:

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
  <lst name="defaults">
  <str name="config">solr-data-config.xml</str>
</lst>

I edit solr-data-config.xml also in solr-6.4.0/example/example-DIH/solr/solr/conf to the following:

    <dataConfig>
<dataSource  type="JdbcDataSource" driver="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/mydatabase" user="postgres" password="pass" />
   <document >
     <entity name="user" query="SELECT first_name FROM main.'user'">
    </entity>
   </document>
</dataConfig>

Note the db connection I have found confusing in posts, but I believe how I included it is correct, with mydatabase being the name of the postgreSQL db. I then Run Solr via bin/solr -e dih. This works and the server is accessible at http://localhost:8983/solr

However when I try to pull data via http://localhost:8983/solr/#/collection1/dataimport//dataimport I get the error

Sorry, no dataimport-handler defined!

And my data schema:

<?xml version="1.0" encoding="UTF-8" ?>
    <schema name="example-DIH-solr" version="1.6">
     <types>
        <fieldType name="string" class="solr.TextField">
          <analyzer>
          <tokenizer class="solr.StandardTokenizerFactory"/>
          </analyzer>
        </fieldType>
     </types>
     <fields>
        <field name="first_name" type="string" indexed="true" stored="true"/>
        <field name="_version_" type="string" indexed="true" stored="true"/>
     </fields>
    <uniqueKey>first_name</uniqueKey>
    </schema>

Thank you for any help you can provide.


Solution

  • That message is a result of a bug in the admin UI, specific to the 6.4.0 version

    https://issues.apache.org/jira/browse/SOLR-10035

    The issue details how you can fix the admin UI.

    Note that this will not affect the actual operation of the dataimport handler, just the admin UI. Usage of Solr is not normally accomplished through the admin UI.