thsr.expand(
query as cts.query,
entries as Sequence,
entries as (element() | Object)[],
new-weight as Number?,
min-weight as Number?,
filter as Node[]
) as cts.query
Summary
Returns a query that searches for all the query strings specified in $query
and their synonyms as found in $entries.
Parameters |
query |
A cts.query item from any of the
cts.*Query functions (
cts.wordQuery ,
cts.andQuery , and so on).
Thesaurus expansion only occurs on an "unwildcarded"
cts.query ;
it cannot expand "wildcarded" queries.
|
entries |
An array of thesaurus entries, can be xml elements or javascript objects.
|
entries |
An array of thesaurus entries, can be XML elements or javascript
objects.
|
new-weight |
A new weight for the relevance ranking. If $new-weight is the empty
sequence, then the relevance ranking is inherited from the parent query.
|
min-weight |
A minimum weight for the relevance ranking. If $min-weight is not the
empty sequence then only queries with weight less than or equal to
$min-weight will be expanded. Otherwise, all queiries are expanded.
|
filter |
Only return entries containing a node that is deep equal to at
least one of the XML nodes specified by this parameter. The filter
nodes must be nodes that can be found in a thesaurus entry. For example,
<thsr:qualifier>birds</thsr:qualifier> .
|
Example
const thsr = require("/MarkLogic/thesaurus");
cts.search(
cts.doc("/Docs/hamlet.xml").root.xpath("//LINE"),
thsr.expand(
cts.wordQuery("weary"),
thsr.lookup("/myThsrDocs/thesaurus.xml",
"weary"),
(),
(),
() )
)
=> This query returns all of the lines in Shakespeare's
Hamlet that have the word "weary" or any of the
synonyms of the word "weary" :)
Copyright © 2024 MarkLogic Corporation. MARKLOGIC is a
registered trademark of MarkLogic Corporation.