![]() |
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 OData, you can easily import OData services 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 OData services for use in enterprise search.
CData simplifies access and integration of live OData services data. Our customers leverage CData connectivity to:
Customers use CData's solutions to regularly integrate their OData services with preferred tools, such as Power BI, MicroStrategy, or Tableau, and to replicate data from OData services to their databases or data warehouses.
> 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
ODataUniqueKeyπ Define schema in Solr for OData services.
Now we are ready to use OData services 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.odata.ODataDriver" url="jdbc:odata:URL=http://services.odata.org/V4/Northwind/Northwind.svc;UseIdUrl=True;OData Version=4.0;Data Format=ATOM;">
</dataSource>
<document>
<entity name="Orders"
query="SELECT Id,ODataColumn1,ODataColumn2,ODataColumn3,ODataColumn4,ODataColumn5,ODataColumn6,ODataColumn7,LastModifiedDate FROM Orders"
deltaQuery="SELECT Id FROM Orders where LastModifiedDate >= '${dataimporter.last_index_time}'"
deltaImportQuery="SELECT Id,ODataColumn1,ODataColumn2,ODataColumn3,ODataColumn4,ODataColumn5,ODataColumn6,ODataColumn7,LastModifiedDate FROM Orders where Id=${dataimporter.delta.Id}">
<field column="Id" name="Id" ></field>
<field column="ODataColumn1" name="ODataColumn1" ></field>
<field column="ODataColumn2" name="ODataColumn2" ></field>
<field column="ODataColumn3" name="ODataColumn3" ></field>
<field column="ODataColumn4" name="ODataColumn4" ></field>
<field column="ODataColumn5" name="ODataColumn5" ></field>
<field column="ODataColumn6" name="ODataColumn6" ></field>
<field column="ODataColumn7" name="ODataColumn7" ></field>
<field column="LastModifiedDate" name="LastModifiedDate" ></field>
</entity>
</document>
</dataConfig>> solr stop -all > solr start
Using the CData JDBC Driver for OData you are able to create an automated import of OData services 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 OData Driver to get started:
Download NowLearn more:
π OData IconEasy-to-use OData client (consumer) enables developers to build Java applications that easily communicate with OData services.