cassandra-lucene-index icon indicating copy to clipboard operation
cassandra-lucene-index copied to clipboard

Index text field as JSON

Open rbkio opened this issue 6 years ago • 2 comments

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?

rbkio avatar Nov 08 '18 11:11 rbkio

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

dbapramod882 avatar Nov 09 '18 15:11 dbapramod882

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.

rbkio avatar Nov 12 '18 06:11 rbkio