You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 5.1 version.
Session: Querying: How to use Lucene
Lucene flavored syntax can be used with the
whereLucene method, a part of the filtering methods available in
IDocumentQuery<T> whereLucene(String fieldName, String whereClause);
|fieldName||String||Name of a field in an index (default field)|
|whereClause||String||Lucene-syntax based clause|
session .advanced() .documentQuery(Company.class) .whereLucene("Name", "bistro") .toList();
from Companies where lucene(Name, 'bistro')
fieldName argument corresponds to Lucene's default field convention. It is mandatory to pass it to the
.whereLucene but the
whereClause can contain clause that omits the field entirely giving you the opportunity to pass a complex expression e.g.
.whereLucene("Name", "Name:bistro OR Phone:981-443655"). It is advised to use this approach against Static Index where all fields are known, because there is no guarantee that a proper Auto Index will be created or used.