Public | Automated Build

Last pushed: 2 years ago
Short Description
This repository contains Apache Cassandra bundled with Lucene
Full Description

Tags & Dockerfiles

About this repository

The repository adds Lucene Index to Apache Cassandra for full-text search by adding a magic column (see example below, more information here: Stratio Cassandra Lucene Plugin)

Lucene Example

Create Keyspace & Table

CREATE KEYSPACE demo WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor': 1};
USE demo;
CREATE TABLE tweets (
  id INT PRIMARY KEY,
  user TEXT,
  body TEXT,
  lucene TEXT
);

Note the field lucene in the table, which is a magic column to query (see below).

Create Lucene Index on Table

CREATE CUSTOM INDEX tweets_index ON tweets (lucene)
USING 'com.stratio.cassandra.lucene.Index'
WITH OPTIONS = {
  'refresh_seconds': '1',
  'schema': '{
    fields: {
      id: {type: "integer"},
      user: {type: "string"},
      body  : {type : "text", analyzer : "english"}
    }
  }'
};

Add some data

INSERT INTO tweets (id, user, body) VALUES (1, 'Adam', 'some text from Adam');
INSERT INTO tweets (id, user, body) VALUES (2, 'Ben', 'some text from Ben');
INSERT INTO tweets (id, user, body) VALUES (3, 'Ben', 'even more text from Ben');
INSERT INTO tweets (id, user, body) VALUES (4, 'Constantine', 'text without username');

Run full-text search

SELECT * FROM tweets WHERE lucene='{ query : {type:"contains", field:"body", values:["without"]} }';
SELECT * FROM tweets WHERE lucene='{ query : {type:"match", field:"user", value:"Constantine"} }';

For more options, check out Lucene Homepage and/or Stratio Cassandra Lucene Plugin.

Links

Docker Pull Command
Owner
cpelka
Source Repository