How to effectively cross 2 or more pieces of cassandra?

I use Posts and TaggedPosts column families as shown in this example

I would like to find posts tagged with 'A', 'B' and 'C' (for example)

the problem is that I have to completely read TaggedPosts with key A, and not just extract the first 10 results, as shown in the example, and then intersect with all TaggedPosts with key B, so as not to miss one, etc.

This is super inefficient, what would be your advice to do this?

I thought to change the structure of TaggedPosts: and put Posts ids as Rows and

create colmun familty TaggedPosts with ... and column_metadata=[
    {column_name: tag1, ..., index_type: KEYS},
    {column_name: tag2, ..., index_type: KEYS},
    {column_name: tag3, ..., index_type: KEYS},

and execute:

get TaggedPosts where tag1=A and tag2=B and tag3=C;

but not sure if this will be much more efficient than client side crossing / filtering

+3
source share
1 answer

, , , N, , .

, , , , , ​​ (cql3):

CREATE COLUMNFAMILY TaggedPosts (
    tag text,
    post uuid,
    blog_rowentries_rowkey text,
    PRIMARY KEY (tag, post)
) WITH COMPACT STORAGE;

-- (note that this is the same actual data layout used in the "wtf is a supercolumn" article)

" A", " B" .., :

SELECT * FROM TaggedPosts WHERE tag = 'A' LIMIT 100;
SELECT * FROM TaggedPosts WHERE tag = 'B' LIMIT 100;

.. , . 100 ; , , . , , , . , , uuid , .

, , Solr, , Datastax Enterprise Solr . ( : Datastax.)

, , .

+2

All Articles