You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: Querying: How to Query With Exact Match

By default, the whereXXX methods in query uses a case-insensitive match.

To perform a case-sensitive match you should use the exact parameter.


IDocumentQuery<T> whereEquals(String fieldName, Object value, boolean exact);
IDocumentQuery<T> whereNotEquals(String fieldName, Object value, boolean exact);

// ... rest of where methods
fieldName String Object field to use
value Object Predicate value
exact boolean Indicates if predicate should be matched in case-sensitive manner

Example I - Query With Exact Match

// load all entities from 'Employees' collection
// where firstName equals 'Robert' (case sensitive match)
List<Employee> employees = session.query(Employee.class)
    .whereEquals("FirstName", "Robert", true)
from Employees where exact(FirstName == 'Robert')

Example II - Query With Inner Exact Match

// return all entities from 'Orders' collection
// which contain at least one order line with
// 'Singaporean Hokkien Fried Mee' product
// perform a case-sensitive match
List<Order> orders = session.query(Order.class)
    .whereEquals("Lines[].ProductName", "Singaporean Hokkien Fried Mee", true)
from Orders 
where exact(Lines[].ProductName == 'Singaporean Hokkien Fried Mee')