Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Index text field as JSON #404

Open
rbkio opened this issue Nov 8, 2018 · 2 comments
Open

Index text field as JSON #404

rbkio opened this issue Nov 8, 2018 · 2 comments

Comments

@rbkio
Copy link

rbkio commented Nov 8, 2018

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
Copy link

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

@rbkio
Copy link
Author

rbkio commented Nov 12, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants