QueryHelpers
contains
Requires that string
must exist in the entity.
Queries that are constructed by using this method produce an index match, not an exact match.
The segment of a query that this method adds is the same as entering the following string for an Engine query: string
Syntax
query contains(string string)
.where(contains("foo"))
.where("foo")
.where(contains("foo").before(contains("bar"))
.where("foo BEFORE bar")
field
Requires that the name
field must exist.
After you specify the field name, type a period (.) and chain additional methods to further specify the data that you want to return.
Additional methods can return queries, sorts, and facets.
The segment of a query that this method adds is the same as entering the following string for an Engine query: CONTENT name
Syntax
data_method field(string name)
.where(field("field-name"))
.where("CONTENT field-name")
.where(field("foo").contains("bar").and(field("baz")))
.where("CONTENT foo CONTAINING bar CONTENT baz")
words
Requires that a span of length
words must exist.
The segment of a query that this method adds is the same as entering the following string for an Engine query: length
WORDS
Syntax
query words(int length)
.where(words(5))
.where("WORDS 5")
.where(field("field-name").containing(words(5)))
.where("CONTENT field-name CONTAINING 5 WORDS")
regex
Requires that regex
must match text in the entity.
POSIX and PCRE regular expression syntaxes are supported.
The segment of a query that this method adds is the same as entering the following string for an Engine query: m/ regex
/
Syntax
query regex(string regex)
.where(regex("fo.+"))
.where("m/fo.+/")
entity_types
Searches the specified entity types.
You can specify one entity type as a string or an array of entity types as strings.
The segment of a query that this method adds has no equivalent for Engine.
entity_type
and entity_types
are aliases for each other.
Syntax
entity_types(string/array entity_types, string context)
entity_types("foo")
entity_types(["foo", "bar"])
entity_type
Searches the specified entity types.
You can specify one entity type as a string or an array of entity types as strings.
The segment of a query that this method adds has no equivalent for Engine.
entity_type
and entity_types
are aliases for each other.
Syntax
entity_type(string/array entity_types, string context)
entity_types("foo")
entity_types(["foo", "bar"])
xpath
Adds an XPath expression that can be used for filtering, sorting and faceting. The segment of a query that this method adds is not exposed for Engine.
Syntax
data_method xpath(string xpath)
.sorted_by(xpath("substring-after($first-and-last-name, ' ')"))
sum
Adds a faceting calculation for summation.
The segment of a query that this method adds is not exposed for Engine.
field
can be the field method, the xpath method, or the name of a field.
Example usage: faceted_by( field( "author" ).with_facet_id( "some_id" ).without_pruning.then( sum( field( "revenue" ) ) )
Syntax
facet_by sum(data_method/string field)
faceted_by(field("author").with_facet_id("some_id").without_pruning.then(sum(xpath("$revenue")))
min
Adds a faceting calculation for minimum.
The segment of a query that this method adds is not exposed for Engine.
field
can be the field method, the xpath method, or the name of a field.
Example usage: faceted_by( field( "author" ).with_facet_id( "some_id" ).without_pruning.then( min( field( "year" ) ) )
Syntax
facet_by min(data_method/string field)
faceted_by(field("author").with_facet_id("some_id").without_pruning.then(min(xpath('$year')))
max
Adds a faceting calculation for maximum.
The segment of a query that this method adds is not exposed for Engine.
field
can be the field method, the xpath method, or the name of a field.
Example usage: faceted_by( field( "author" ).with_facet_id( "some_id" ).without_pruning.then( max( field( "year" ) ) )
Syntax
facet_by max(data_method/string field)
faceted_by(field("author").with_facet_id("some_id").without_pruning.then(max(xpath('$year')))
avg
Adds a faceting calculation for average.
The segment of a query that this method adds is not exposed for Engine.
field
can be the field method, the xpath method, or the name of a field.
Example usage: faceted_by( field( "year" ).with_facet_id( "some_id" ).without_pruning.then( avg( field( "sales" ) ) )
Syntax
facet_by avg(data_method/string field)
faceted_by(field("year").with_facet_id("some_id").without_pruning.then(avg(xpath('$sales')))
stddev
Adds a faceting calculation for standard deviation.
The segment of a query that this method adds is not exposed for Engine.
field
can be the field method, the xpath method, or the name of a field.
Example usage: faceted_by( field( "year" ).with_facet_id( "some_id" ).without_pruning.then( stddev( field( "sales" ) ) )
Syntax
facet_by stddev(data_method/string field)
faceted_by(field("year").with_facet_id("some_id").without_pruning.then(stddev(xpath('$sales')))