Stratio / cassandra-lucene-index

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

Query maps where value is case_sensitive=false #406

Open ayashjorden opened 5 years ago

ayashjorden commented 5 years ago

Hello Stratio! Thank you for this great library! I've searched the issues for similar question as mine, but couldn't find any. Also on SO, still nothing.

I'm trying to figure out how to query a Map<text, text> column, where I'd like that the match on the value would be case-insensitive.

My index:

CREATE CUSTOM INDEX index_v1 ON accounts () USING 'com.stratio.cassandra.lucene.Index' WITH OPTIONS = {'refresh_seconds': '1', 'schema': '{
      fields: {
        "meta_data": {type: "string"},
        "meta_data._key": {type: "string"},
        "meta_data._value": {type: "string", case_sensitive: false},
        "name":  {type: "string"}
      }
  }'};

For example, lets say that the Map contains Environment=Prd, The following query returns empty result:

SELECT * FROM accounts WHERE expr(index_v1, '{filter:{type:"match",field:"meta_data$Environment",value:"prd"}}');

UPDATE

Setting the "meta_data": {type: "string"} => "meta_data": {type: "string", case_sensitive: false}, did the trick. it queries the values case-insensitive. BUT, I'm now curios about the following: querying keys is case sensitive, even though that the case_sensitive: false is at the meta_data level (over the whole map??). Querying EnVironment=Prd will result in nothing.

Can you reason about this?

Appreciate your help, Yarden