2

Im trying to use couchDB, ektorp to store and query data If i have documents like

Sofa{
    colour:red   manufaturedDate: 12/8/2015
}

how can i create a view and query it.. so i can answer give me all Sofas that are in a set or arbitrary colours AND have been manufactured between certain days..

the user can search for what ever colours they want and select whatever days they like in sudo SQL i would write something like

select* from Sofa where manufaturedDate is inbetween date1 and date 2 and colour in ('red', 'blue', 'orange');

But im having difficulty creating the equivilant in couchDB/ektorp i can create view

[red, 12/8/2015] = {Sofa1}

I know i can search by mutilpe keys but i dont know how to query it using both "types" of criteria.

i can either do

ComplexKey start = ComplexKey.of(query.getStartKey());
ComplexKey end = ComplexKey.of(query.getEndKey());
view2.startKey(start).endKey(end);

OR

for(Object[] sample:query.getKeyValues()){
    keys.add(ComplexKey.of(sample));
}
view2.keys(keys);

How can i do both.. Am i looking at this the wrong way?

darthShana
  • 367
  • 1
  • 4
  • 16

0 Answers0