This action will force synchronization from 白乔/solr-sql, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
中文版: https://github.com/bluejoe2008/solr-sql/blob/master/README_CN.md
solr-sql provides sql interfaces for solr cloud(http://lucene.apache.org/solr/), by which developers can operate on solr cloud via JDBC protocols.
On the same time, solr-sql is an Apache Calcite(see http://calcite.apache.org) adapter for solr.
solr-sql is written in Scala, which generates JVM byte codes like Java.
This project is hosted on http://github.com/bluejoe2008/solr-sql.
So, if you are a Java developer, do not hesitate to choose solr-sql, because it is easy to be referenced by Java code. Also the test cases are written in Java(see https://github.com/bluejoe2008/solr-sql/blob/master/src/java/test/SolrSqlQueryTest.java).
If you are interested in source codes, manybe you need install a ScalaIDE(http://scala-ide.org/), or scala plugins for eclipse.
solr-sql uses Maven to manage libary dependencies, it is a normal Maven project.
use maven to import solr-sql:
<dependency>
<groupId>com.github.bluejoe2008</groupId>
<artifactId>solr-sql</artifactId>
<version>0.9</version>
</dependency>
example code:
Properties info = new Properties();
info.setProperty("lex", "JAVA");
Connection connection = DriverManager.getConnection(
"jdbc:calcite:model=src/java/test/model.json", info);
Statement statement = connection.createStatement();
String sql = "select * from docs where not (age>35 and name='bluejoe')";
ResultSet resultSet = statement.executeQuery(sql);
this illustrates how to connect to a solr 'database' in JDBC client manners, the schema of 'database' is defined in file 'src/java/test/model.json'.
the file 'src/java/test/model.json' shows an example schema definition as below:
{
version: '1.0',
defaultSchema: 'solr',
schemas:
[
{
name: 'solr',
tables:
[
{
name: 'docs',
type: 'custom',
factory: 'org.apache.calcite.adapter.solr.SolrTableFactory',
operand:
{
solrServerURL: 'http://bluejoe1:8983/solr/collection1',
solrCollection: 'collection1',
//solrZkHosts: 'bluejoe1:9983',
columns:'id integer, name char, age integer',
columnMapping: 'name->name_s, age->age_i'
}
}
]
}
]
}
this defines a custom table named 'docs', several arguments can be defined in the operand field:
https://github.com/bluejoe2008/solr-sql/blob/master/src/java/test/SolrSqlQueryTest.java shows how to connect to a JDBC source of solr.
https://github.com/bluejoe2008/solr-sql/blob/master/src/java/test/SqlTranslatorTest.java tests if the translation from SQL filters to Solr filters is right, like:
Assert.assertEquals("age_i:{20 TO *}",
trans("select * from docs where age>20"));
a SqlFilter2SolrFilterTranslator translates a SQL filter to a Solr filter. a SQL filter is represented by a Calcite RexNode object, and a solr filter is represented by a SolrFilter object. There are serveral SolrFilters defined in this project:
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。