![]() |
VOOZH | about |
The Apache Solr platform is a popular, blazing-fast, open source enterprise search solution built on Apache Lucene.
Apache Solr is equipped with the Data Import Handler (DIH), which can import data from databases and, XML, CSV, and JSON files. When paired with the CData JDBC Driver for Gmail, you can easily import Gmail data to Apache Solr. In this article, we show step-by-step how to use CData JDBC Driver in Apache Solr Data Import Handler and import Gmail data for use in enterprise search.
> solr create -c CDataCoreFor this article, Solr is running as a standalone instance in the local environment and you can access the core at this URL: http://localhost:8983/solr/#/CDataCore/core-overview
GmailUniqueKeyπ Define schema in Solr for Gmail data.
Now we are ready to use Gmail data in Solr.
In this section, we walk through configuring the Data Import Handler.
<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-.*\.jar" />
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">solr-data-config.xml</str>
</lst>
</requestHandler>
<dataConfig>
<dataSource driver="cdata.jdbc.gmail.GmailDriver" url="jdbc:gmail:User=username;Password=password;">
</dataSource>
<document>
<entity name="Inbox"
query="SELECT Id,GmailColumn1,GmailColumn2,GmailColumn3,GmailColumn4,GmailColumn5,GmailColumn6,GmailColumn7,LastModifiedDate FROM Inbox"
deltaQuery="SELECT Id FROM Inbox where LastModifiedDate >= '${dataimporter.last_index_time}'"
deltaImportQuery="SELECT Id,GmailColumn1,GmailColumn2,GmailColumn3,GmailColumn4,GmailColumn5,GmailColumn6,GmailColumn7,LastModifiedDate FROM Inbox where Id=${dataimporter.delta.Id}">
<field column="Id" name="Id" ></field>
<field column="GmailColumn1" name="GmailColumn1" ></field>
<field column="GmailColumn2" name="GmailColumn2" ></field>
<field column="GmailColumn3" name="GmailColumn3" ></field>
<field column="GmailColumn4" name="GmailColumn4" ></field>
<field column="GmailColumn5" name="GmailColumn5" ></field>
<field column="GmailColumn6" name="GmailColumn6" ></field>
<field column="GmailColumn7" name="GmailColumn7" ></field>
<field column="LastModifiedDate" name="LastModifiedDate" ></field>
</entity>
</document>
</dataConfig>> solr stop -all > solr start
Using the CData JDBC Driver for Gmail you are able to create an automated import of Gmail data into Apache Solr. Download a free, 30 day trial of any of the hundreds of CData JDBC Drivers and get started today.
Download a free trial of the Gmail Driver to get started:
Download NowLearn more:
π Gmail IconRapidly create and deploy powerful Java applications that integrate powerful Gmail send and receive capabilities. . Send & Receive Email, manage Gmail folders & Messages, and more!