![]() |
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 Square, you can easily import Square 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 Square 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
SquareUniqueKeyπ Define schema in Solr for Square data.
Now we are ready to use Square 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.square.SquareDriver" url="jdbc:square:OAuthClientId=MyAppId;OAuthClientSecret=MyAppSecret;CallbackURL=http://localhost:33333;LocationId=MyDefaultLocation;InitiateOAuth=GETANDREFRESH;">
</dataSource>
<document>
<entity name="Refunds"
query="SELECT Id,SquareColumn1,SquareColumn2,SquareColumn3,SquareColumn4,SquareColumn5,SquareColumn6,SquareColumn7,LastModifiedDate FROM Refunds"
deltaQuery="SELECT Id FROM Refunds where LastModifiedDate >= '${dataimporter.last_index_time}'"
deltaImportQuery="SELECT Id,SquareColumn1,SquareColumn2,SquareColumn3,SquareColumn4,SquareColumn5,SquareColumn6,SquareColumn7,LastModifiedDate FROM Refunds where Id=${dataimporter.delta.Id}">
<field column="Id" name="Id" ></field>
<field column="SquareColumn1" name="SquareColumn1" ></field>
<field column="SquareColumn2" name="SquareColumn2" ></field>
<field column="SquareColumn3" name="SquareColumn3" ></field>
<field column="SquareColumn4" name="SquareColumn4" ></field>
<field column="SquareColumn5" name="SquareColumn5" ></field>
<field column="SquareColumn6" name="SquareColumn6" ></field>
<field column="SquareColumn7" name="SquareColumn7" ></field>
<field column="LastModifiedDate" name="LastModifiedDate" ></field>
</entity>
</document>
</dataConfig>> solr stop -all > solr start
Using the CData JDBC Driver for Square you are able to create an automated import of Square 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 Square Driver to get started:
Download NowLearn more:
π Square IconEasy-to-use Square client enables Java-based applications to easily consume Square Transactions, Items, Subscriptions, etc.