0

I have the following documents in collection

{
    "_id" : ObjectId("53202b3644aec3ce32afc40b"),
    "_class" : "com.brand.domain.House",
    "bedrooms" : 2,
    "uid" : "URErlrjldVhW",
    "price" : NumberLong(200),
    "type" : "RENT",
    "address" : " test",
    "details" : " test",
    "rentType" : "perMonth"
}
{
    "_id" : ObjectId("53202b4444aec3ce32afc40c"),
    "_class" : "com.brand.domain.House",
    "bedrooms" : 2,
    "uid" : "SHvPruOJuivg",
    "price" : NumberLong(300),
    "type" : "RENT",
    "address" : " ",
    "details" : " ",
    "rentType" : "perMonth"
}

And with the following query using query builder, it returns empty array

My input values are

type : RENT
maxPrice : 5000
minPrice : 100
bedRooms : 2

And the query

Query query = new Query(
    where("type")
    .is(form.getType())
    .and("price")
    .lte(form.getMaxPrice())
    /*.gte(form.getMinPrice())*/
    .and("bedRooms")
    .is(form.getMinBedRooms()));

And following are form fields

private String type;
private long minPrice;
private long maxPrice;
private int minBedRooms;

Can any one kindly help me what is wrong with my query. Thanks in advance.

Neil Lunn
  • 148,042
  • 36
  • 346
  • 317
Shahzeb Khan
  • 3,582
  • 8
  • 45
  • 79

2 Answers2

0

Isn't "Query" a sping data class? So then:

    Query searchQuery = new Query(Criteria.where("type")
            .is("RENT")
            .and("price")
            .lte(5000)
            .and("bedrooms")
            .is(2));

    System.out.println( searchQuery );

Printing or logging the object usually help me see it is doing what I want.

Neil Lunn
  • 148,042
  • 36
  • 346
  • 317
0

You have a spelling mistake.

Change berdRooms to bedrooms

According to JSON-RPC spec:

6.5. Case-Sensitivity of Procedure and Parameter Names

Conforming implementations MUST treat procedure and parameter names as being case-sensitive such the names bar and BAR would be seen as two distinct entities.

jfcorugedo
  • 9,793
  • 8
  • 39
  • 47