Java Query Builder¶
This module1 eases the building of the JSON statements used by advanced lucene index.
If your want to use it with Spring Data see Spring Data 2.0 integration.
If you are using Maven you can use it by adding this dependency to your pom.xml:
<dependency> <groupId>org.hawkore.libs.ignite</groupId> <artifactId>hk-ignite-lucene-builder</artifactId> <version>2.8.1-hk</version> </dependency>
Then you can build an index creation statement this way:
import static org.hawkore.ignite.lucene.builder.Builder.*; (...) Index index = index("keyspace_name", "table_name") .refreshSeconds(10) .defaultAnalyzer("english") .analyzer("danish", snowballAnalyzer("danish")) .mapper("id", uuidMapper()) .mapper("user", stringMapper().caseSensitive(false)) .mapper("message", textMapper().analyzer("danish")) .mapper("date", dateMapper().pattern("yyyyMMdd")); System.out.println("Sample JSON lucene index configuration from code:\n" + index.build()); System.out.println("Sample DDL CREATE INDEX statement from code:\n" + index.buildDDL()); ignite.context().query().querySqlFields(new SqlFieldsQuery(index.buildDDL()), false).getAll();
And you can also build searches in a similar fashion:
import static org.hawkore.ignite.lucene.builder.Builder.*; (...) String query = "SELECT * FROM \"test\".user WHERE lucene = ?"; SqlFieldsQuery q = new SqlFieldsQuery(query); q.setArgs(search().filter(range("age").lower(65).includeLower(true)).build()); List<List<?>> resultSet = ignite.context().query().querySqlFields(q, false).getAll();
-
It is an adapted version of Stratio's Query builder for Cassandra to Apache Ignite requirements. ↩