Multiple predicates
Operators
Operators allow terms to be combined through logical operators. sensenet query language supports AND, "+", OR, NOT and "-" as Boolean operators (boolean operators must be ALL CAPS like keywords).
The OR
operator is the default conjunction operator. This means that if there is no operator between two terms, the OR
operator is used. The OR
operator links two terms and finds a matching document if either of the terms exist in a document. This is equivalent to a union using sets.
The AND
operator matches documents where both terms exist anywhere in the text or fields of a single document. To search for event that have the type demo and meeting in the field EventType, use this query:
https://dev.demo.sensenet.com/OData.svc/Root/Content/IT?query=EventType%3ADemo AND EventType%3AMeeting
// the special characters should be url encoded
// the actual query here is ?query=EventType:Demo AND EventType:Meeting
The + or required operator requires that the term after the "+" symbol exist somewhere in a the field of a single document.
To search for content that must contain meeting type events and may contain demo events use the query:
https://dev.demo.sensenet.com/OData.svc/Root/Content/IT?query=+EventType%3ADemo +EventType%3AMeeting
// the special characters should be url encoded
// the actual query here is ?query=+EventType:Demo AND +EventType:Meeting
The NOT
operator excludes content that contain the term after NOT
. (It cannot be used with only one term.)
The "-" or prohibit operator excludes documents that contain the term after the "-" symbol.
To search for content that contain "upgrade" but not "demo" use the query:
Grouping
sensenet query language supports use of parentheses to group clauses and form sub queries.
Following query demonstrate how you can group multiple predicates:
https://dev.demo.sensenet.com/OData.svc/Root/Content/IT?query=(EventType%3ADemo AND EventType%3AMeeting) OR EventType%3ADeadline
// the special characters should be url encoded
// the actual query here is ?query=(EventType:Demo AND EventType:Meeting) OR EventType:Deadline