<?xml version="1.0" encoding="utf-8"?>

<!-- EngineVersion = Java version -->
<ApiConfig Name="Apache Solr"
           Slug="apache-solr-connector"
           Type="JDBC"
           Category="search"
           Id="F574358C-EA49-5F31-854F-45B50B00B2BE"
           Version="1"
           EngineVersion="11"
           Desc="Query Apache Solr collections with SQL JDBC from Power BI, SQL Server Linked Server via ZappySys Data Gateway, Crystal Reports, SSRS, Azure Data Factory, and other ODBC tools -- almost no coding required."
           Logo="https://cdn.zappysys.com/api/Images/logos/apache-solr-connector.png"
           HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">

    <VersionHistory>
      <Change Ver="1" Date="2026-09-15" Type="New">Initial JDBC Bridge catalog version. Hands-free JAR download. Auth Notes and SQL examples for ODBC apps.</Change>
    </VersionHistory>
    <Template>
        <Param Name="DriverDownloadPageLink"
               Value="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
        <Param Name="MvnRepositoryDriverDownloadLink"
               Value="https://mvnrepository.com/artifact/org.apache.solr/solr-solrj" />
        <Param Name="DriverDownloadLinks"
               Hidden="True"
               Value="solr-solrj-9.10.1.jar=https://repo1.maven.org/maven2/org/apache/solr/solr-solrj/9.10.1/solr-solrj-9.10.1.jar;solr-solrj-streaming-9.10.1.jar=https://repo1.maven.org/maven2/org/apache/solr/solr-solrj-streaming/9.10.1/solr-solrj-streaming-9.10.1.jar;solr-solrj-zookeeper-9.10.1.jar=https://repo1.maven.org/maven2/org/apache/solr/solr-solrj-zookeeper/9.10.1/solr-solrj-zookeeper-9.10.1.jar" />
        <EndPoint Name="AdditionalDriverDownloadInstructions">
            <Body>
                <![CDATA[<li>
            <p>
                There is no official Solr JDBC fat JAR. The wizard downloads SolrJ 9.10.1 plus
                <code>solr-solrj-streaming</code> (JDBC <code>DriverImpl</code>) and
                <code>solr-solrj-zookeeper</code> (ZooKeeper mode).
            </p>
        </li>
        <li>
            <p>
                Copy the remaining runtime JARs from a matching Solr 9 install:
                <code>$SOLR_TIP/server/solr-webapp/webapp/WEB-INF/lib/*</code>
                and <code>$SOLR_TIP/server/lib/ext/*</code>.
                Add those paths on the DSN Main UI (semicolon-separated) if Test Connection reports missing classes.
            </p>
        </li>
        <li>
            <p>
                The target collection must expose the <code>/sql</code> request handler.
                Pin SolrJ <strong>9.x</strong> (not 10) to match EngineVersion 11.
            </p>
        </li>]]>
            </Body>
        </EndPoint>
    </Template>

    <Auths>
        <Auth Name="Zk"
              Label="ZooKeeper (SolrCloud)"
              ConnStr="jdbc:solr://[$HostName$]:[$Port$]?collection=[$Collection$]"
              HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Params>
                <Param Name="DriverClass" Label="Driver class" Required="False" Value="org.apache.solr.client.solrj.io.sql.DriverImpl" Desc="Optional. Leave blank to auto-detect from the JAR unless SPI is ambiguous (e.g. org.apache.solr.client.solrj.io.sql.DriverImpl)." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="DriverFilePaths" Editor="FileOpen" Label="JDBC driver file(s)" Required="True" Value="{DownloadFolder}\solr-solrj-9.10.1.jar;{DownloadFolder}\solr-solrj-streaming-9.10.1.jar;{DownloadFolder}\solr-solrj-zookeeper-9.10.1.jar" Desc="Filled by the wizard after download. Include SolrJ, streaming, and ZooKeeper JARs. Add WEB-INF/lib and server/lib/ext if Test Connection reports missing classes (e.g. C:\ZappySys\Jdbc\MyConnector\driver.jar)." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="HostName" Label="Host" Required="True" Value="MyHostName" Desc="JDBC host name or IP (e.g. MyHostName)." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="Port" Label="TCP port" Required="True" Value="2181" Desc="JDBC port (e.g. 2181)." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="Collection" Label="Collection" Required="True" Value="MyCollection" Desc="Solr collection name (e.g. MyCollection)." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="UserName" Label="User name" Required="False" Desc="Database user. Leave empty if the server allows anonymous JDBC." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="Password" Label="Password" Required="False" Secret="True" Desc="Database password. Leave empty if no password is required." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
            </Params>
            <Notes>
                <![CDATA[<p>Apache Solr SQL JDBC from Power BI, SQL Server Linked Server via ZappySys Data Gateway, Crystal Reports, SSRS, Azure Data Factory, and other ODBC tools. The collection must expose <code>/sql</code>. This Auth uses ZooKeeper (SolrCloud).</p>
<ol>
  <li>Note the ZooKeeper host and port (often <code>2181</code>, or Solr's embedded ZK on <code>9983</code> in local examples) and the collection name.</li>
  <li>Confirm the collection has the <code>/sql</code> handler in <code>solrconfig.xml</code>.</li>
  <li>The wizard downloads SolrJ 9.10.1 + streaming + ZooKeeper modules. If Test Connection fails on a missing class, add WEB-INF/lib and server/lib/ext JARs from the same Solr 9 install (see additional download instructions).</li>
  <li>After Finish, replace <code>zkHost</code> and <code>collection</code> on the DSN Main UI. Driver class is <code>org.apache.solr.client.solrj.io.sql.DriverImpl</code> (not auto-obvious from SPI).</li>
  <li>Finish the wizard. Then click <strong>Test Connection</strong> on the DSN Main UI (the wizard does not run Test Connection).</li><li>Done. You can query from C#, Python, PowerShell, and ODBC apps.</li>
</ol>]]>
            </Notes>
        </Auth>
        <Auth Name="Http"
              Label="HTTP"
              ConnStr="jdbc:solr://[$HostName$]:[$Port$]?collection=[$Collection$]"
              HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Params>
                <Param Name="DriverClass" Label="Driver class" Required="False" Value="org.apache.solr.client.solrj.io.sql.DriverImpl" Desc="Optional. Leave blank to auto-detect from the JAR unless SPI is ambiguous (e.g. org.apache.solr.client.solrj.io.sql.DriverImpl)." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="DriverFilePaths" Editor="FileOpen" Label="JDBC driver file(s)" Required="True" Value="{DownloadFolder}\solr-solrj-9.10.1.jar;{DownloadFolder}\solr-solrj-streaming-9.10.1.jar;{DownloadFolder}\solr-solrj-zookeeper-9.10.1.jar" Desc="Filled by the wizard after download. Include SolrJ, streaming, and ZooKeeper JARs. Add WEB-INF/lib and server/lib/ext if Test Connection reports missing classes (e.g. C:\ZappySys\Jdbc\MyConnector\driver.jar)." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="HostName" Label="Host" Required="True" Value="MyHostName" Desc="JDBC host name or IP (e.g. MyHostName)." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="Port" Label="TCP port" Required="True" Value="2181" Desc="JDBC port (e.g. 2181)." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="Collection" Label="Collection" Required="True" Value="MyCollection" Desc="Solr collection name (e.g. MyCollection)." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="UserName" Label="User name" Required="False" Desc="Database user. Leave empty if the server allows anonymous JDBC." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
                <Param Name="Password" Label="Password" Required="False" Secret="True" Desc="Database password. Leave empty if no password is required." HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html" />
            </Params>
            <Notes>
                <![CDATA[<p>Solr SQL over HTTP (no ZooKeeper in the JDBC URL). Still requires <code>/sql</code> on the collection.</p>
<ol>
  <li>Note the Solr node host and HTTP port (default <code>8983</code>) and the collection name.</li>
  <li>If the node is SolrCloud, ZooKeeper Auth is usually more reliable. Use HTTP for standalone Solr or a single node you can reach directly.</li>
  <li>Keep SolrJ 9.x. Do not mix Solr 10 JARs with this EngineVersion 11 profile.</li>
  <li>After Finish, replace host, port, and collection.</li>
  <li>Finish the wizard. Then click <strong>Test Connection</strong> on the DSN Main UI (the wizard does not run Test Connection).</li><li>Done. You can query from C#, Python, PowerShell, and ODBC apps.</li>
</ol>]]>
            </Notes>
        </Auth>
    </Auths>

    <Examples>
        <Example Default="True" Group="ODBC" Slug="list-tables" Label="List tables" HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Desc><![CDATA[<p>Lists tables available to this connection. Use this in Power BI or a SQL Server Linked Server to confirm the catalog before building reports.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT id FROM MyCollection LIMIT 10]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="select-rows" Label="Select rows" HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Desc><![CDATA[<p>Returns rows from <code>MyCollection</code>. Replace the identifier with your catalog object. Works in Excel, SSRS, and Crystal Reports.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT * FROM MyCollection]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="filter-rows" Label="Filter with WHERE" HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Desc><![CDATA[<p>Returns matching rows from <code>MyCollection</code>. Swap the column and literal for your schema.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT * FROM MyCollection
WHERE id = 1]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="group-by" Label="Aggregate with GROUP BY" HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Desc><![CDATA[<p>Counts rows per group. Typical Power BI import pattern before a visual.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT status, COUNT(*) AS row_count
FROM MyCollection
GROUP BY status]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="having" Label="Filter groups with HAVING" HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Desc><![CDATA[<p>Keeps groups whose count is at least 10.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT status, COUNT(*) AS row_count
FROM MyCollection
GROUP BY status
HAVING COUNT(*) >= 10]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="order-limit" Label="Order and limit" HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Desc><![CDATA[<p>Returns the first 100 rows ordered by a column. Useful for preview in Excel or Crystal Reports.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT * FROM MyCollection
ORDER BY id
LIMIT 100]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="count-all" Label="Count rows" HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Desc><![CDATA[<p>Returns the number of rows in <code>MyCollection</code>.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT COUNT(*) AS row_count FROM MyCollection]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="case-expr" Label="CASE expression" HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Desc><![CDATA[<p>Maps a column to labels with <code>CASE</code>.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT id,
       CASE WHEN status = 'A' THEN 'Active' ELSE 'Other' END AS status_label
FROM MyCollection]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="select-list" Label="Select specific columns" HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Desc><![CDATA[<p>Returns a column list instead of star. Prefer this in Linked Server views.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT id, name, status
FROM MyCollection]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="distinct-field" Label="Distinct field values" HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Desc><![CDATA[<p>Returns distinct values of a field. Typical Power BI dimension extract from Solr.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT DISTINCT status FROM MyCollection]]>
            </Code>
        </Example>

        <Example Group="ODBC" Slug="map-reduce-agg" Label="Map-reduce aggregation" HelpLink="https://solr.apache.org/guide/solr/9_10/query-guide/sql-query.html">
            <Desc><![CDATA[<p>Sums a numeric field per group. Requires aggregationMode on the JDBC URL when the collection is large.</p>]]></Desc>
            <Code>
                <![CDATA[SELECT status, SUM(amount) AS total_amount
FROM MyCollection
GROUP BY status
ORDER BY total_amount DESC]]>
            </Code>
        </Example>
    </Examples>
</ApiConfig>
