You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Marcelo Elias Del Valle <mv...@gmail.com> on 2012/09/27 21:47:52 UTC
composite keys criteria
I know this is a basic question, but find the answer is being harder than I
thought.
Assuming a s composite of 3 Strings, and my columns look like:
A:A:A
A:B:B
A:B:C
A:C:B
B:A:A
B:B:A
B:B:B
C:A:B
Can I search for all the columns where the last component is C, whatever
exists on components 0 and 1? Would the following code do the job?
Composite start = new Composite();
start.addComponent(2, "C", Composite.ComponentEquality.EQUAL);
Composite end = new Composite();
end.addComponent(2, "C", Composite.ComponentEquality.EQUAL);
Or the following?
Composite start = new Composite();
start.addComponent(0, "A", Composite.ComponentEquality.EQUAL);
start.addComponent(1, "A", Composite.ComponentEquality.EQUAL);
start.addComponent(2, "A", Composite.ComponentEquality.EQUAL);
Composite end = new Composite();
end.addComponent(0, "B", Composite.ComponentEquality.GREATER_THAN_EQUAL);
end.addComponent(1, "B", Composite.ComponentEquality.GREATER_THAN_EQUAL);
end.addComponent(2, "B", Composite.ComponentEquality.EQUAL);
--
Marcelo Elias Del Valle
http://mvalle.com - @mvallebr
Re: composite keys criteria
Posted by Marcelo Elias Del Valle <mv...@gmail.com>.
Answering to myself, just in case it's doubt of somebody else.
No, it can't be done, as it's only possible to filter anything if partition
key is provided.
http://www.datastax.com/dev/blog/schema-in-cassandra-1-1
2012/9/27 Marcelo Elias Del Valle <mv...@gmail.com>
> I know this is a basic question, but find the answer is being harder than
> I thought.
>
> Assuming a s composite of 3 Strings, and my columns look like:
>
> A:A:A
>
> A:B:B
>
> A:B:C
>
> A:C:B
>
> B:A:A
>
> B:B:A
>
> B:B:B
>
> C:A:B
>
>
> Can I search for all the columns where the last component is C, whatever
> exists on components 0 and 1? Would the following code do the job?
>
>
> Composite start = new Composite();
> start.addComponent(2, "C", Composite.ComponentEquality.EQUAL);
>
> Composite end = new Composite();
> end.addComponent(2, "C", Composite.ComponentEquality.EQUAL);
>
>
> Or the following?
>
> Composite start = new Composite();
>
> start.addComponent(0, "A", Composite.ComponentEquality.EQUAL);
>
> start.addComponent(1, "A", Composite.ComponentEquality.EQUAL);
>
> start.addComponent(2, "A", Composite.ComponentEquality.EQUAL);
>
> Composite end = new Composite();
>
> end.addComponent(0, "B", Composite.ComponentEquality.GREATER_THAN_EQUAL);
>
> end.addComponent(1, "B", Composite.ComponentEquality.GREATER_THAN_EQUAL);
>
> end.addComponent(2, "B", Composite.ComponentEquality.EQUAL);
>
>
>
> --
> Marcelo Elias Del Valle
> http://mvalle.com - @mvallebr
>
--
Marcelo Elias Del Valle
http://mvalle.com - @mvallebr