forked from Impetus/kundera
-
Notifications
You must be signed in to change notification settings - Fork 0
Secondary Index Mapping in Cassandra
chhavigangwal edited this page Nov 6, 2013
·
5 revisions
Cassandra supports secondary indexes of the type KEYS (similar to a hash index). Secondary indexes can be used for querying and applying filters on columns other than primary indexes.
Secondary indexes can be created using Cassandra only if ddl.auto.prepare property is enabled.
<property name="kundera.ddl.auto.prepare" value="create" />
@Entity
@Table(name="property")
@IndexCollection(columns = { @Index(name = "likedBy"), @Index(name = "income"), @Index(name = "settlementDate"),
@Index(name = "dateSet"), @Index(name = "and"), @Index(name = "between"), @Index(name = "or") })
public class Property
{
@Id
private String id;
@Column
private String likedBy;
@Column
private String income;
@Column
private String settlementDate;
@Column
private String dateSet;
@Column
private String and;
@Column
private String between;
@Column
private String or;
@Column
private String set;
An equivalent created in Cassandra for secondary the given object :
CREATE TABLE property (
key text PRIMARY KEY,
"and" text,
between text,
"dateSet" text,
income text,
"likedBy" text,
or text,
"set" text,
"settlementDate" text
);
CREATE INDEX property_and_idx ON property ("and");
CREATE INDEX property_between_idx ON property (between);
CREATE INDEX property_dateSet_idx ON property ("dateSet");
CREATE INDEX property_income_idx ON property (income);
CREATE INDEX property_likedBy_idx ON property ("likedBy");
CREATE INDEX property_or_idx ON property (or);
CREATE INDEX property_settlementDate_idx ON property ("settlementDate");
These indexes can be queried using Kundera in the following manner :
// Select query.
List<Property> entityWithClauses = em.createQuery(
"select t from Property t where t.income=1233").getResultList();
entityWithClauses = em.createQuery("select t from Property t where t.likedBy=kk").getResultList();
entityWithClauses = em.createQuery("select t from Property t where t.dateSet=dateSet").getResultList();
entityWithClauses = em.createQuery("select t from Property t where t.settlementDate=12/12/12")
.getResultList();
entityWithClauses = em.createQuery("select t from Property t where t.or=or").getResultList();
entityWithClauses = em.createQuery("select t from Property t where t.between=between").getResultList();
entityWithClauses = em.createQuery("select t from Property t where t.and=and").getResultList();
-
Datastores Supported
- Releases
-
Architecture
-
Concepts
-
Getting Started in 5 minutes
-
Features
- Object Mapper
- Polyglot Persistence
- Queries Support
- JPQL (JPA Query Language)
- Native Queries
- Batch insert update
- Schema Generation
- Primary Key Auto generation
- Transaction Management
- REST Based Access
- Geospatial Persistence and Queries
- Graph Database Support
-
Composite Keys
-
No hard annotation for schema
-
Support for Mapped superclass
-
Object to NoSQL Data Mapping
-
Cassandra's User Defined Types and Indexes on Collections
-
Support for aggregation
- Scalar Queries over Cassandra
- Connection pooling using Kundera Cassandra
- Configuration
- [Kundera with Couchdb] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with--Couchdb)
- [Kundera with Elasticsearch] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Elasticsearch)
- [Kundera with HBase] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-HBase)
- [Kundera with Kudu] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Kudu)
- [Kundera with MongoDB] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-MongoDB)
- [Kundera with OracleNoSQL] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-OracleNoSQL)
- [Kundera with Redis] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-over-Redis)
- [Kundera with Spark] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Spark)
-
Extend Kundera
- Sample Codes and Examples
- [Blogs and Articles] (https://github.com/impetus-opensource/Kundera/wiki/Blogs--and-Articles)
-
Tutorials
* Kundera with Openshift
* Kundera with Play Framework
* Kundera with GWT
* Kundera with JBoss
* Kundera with Spring
-
Performance
-
Troubleshooting
-
FAQ
- Production deployments
- Feedback