Stratio / cassandra-lucene-index

Lucene based secondary indexes for Cassandra
Apache License 2.0
600 stars 170 forks source link

Index text field as JSON #404

Open rbkio opened 5 years ago

rbkio commented 5 years ago

Is there a way, using stratio index, I can index a text column in my Cassandra table as a json object and query on the keys with in the json?

For example consider the below table structure : CREATE TABLE test (pk int PRIMARY KEY, json_text text, lucene text);

My data in this table looks like this :

pk json_text lucene
1 {"key1":"Value1","key2":"Value2","key3":"Value3"}
2 {"key2":"AnotherValue1","key3":"AnotherValue2","key5":"AnotherValue3"}

Can I create any such index :

CREATE CUSTOM INDEX idx ON test(lucene)
    USING 'com.stratio.cassandra.lucene.Index'
    WITH OPTIONS = {
        'schema': '{
            fields: {
                json_text: {type: "json"}
            }
        }'
    };

And do queries like below or anything similar :

SELECT * FROM test WHERE expr(lucene, '{    
   filter: {    
      type: "match",
      field: "json_text.key1",
      value: "Value1"
   }
}');

I know I can use maps to achieve what I am trying to do here with json text column. But, I have read about and faced issues with huge maps in Cassandra. So, trying to avoid maps and trying to get similar functionality with strings. Any suggestions?

dbapramod882 commented 5 years ago

Can you try "select JSON a, b from....." Not sure if i am correct.

rbkio commented 5 years ago

My intention here is not to get results back as JSON, but to index my string column as json. Checking if something of this sort is possible with Stratio indexes.