[MarkLogic Dev General] using search:parse/search:unparse and thsr:query-lookup/thsr:expand
Treskon, Matthew
Matthew.Treskon at ARS.USDA.GOV
Fri Jun 22 10:41:49 PDT 2012
Yes. the output of thsr:expand (which looks right) is not an element (according to search:unparse).
Matthew
________________________________
From: general-bounces at developer.marklogic.com [general-bounces at developer.marklogic.com] on behalf of Will Thompson [wthompson at jonesmcclure.com]
Sent: Friday, June 22, 2012 1:23 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] using search:parse/search:unparse and thsr:query-lookup/thsr:expand
Have you tried thsr:expand()?
-Will
From: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] On Behalf Of Treskon, Matthew
Sent: Friday, June 22, 2012 10:03 AM
To: general at developer.marklogic.com
Subject: [MarkLogic Dev General] using search:parse/search:unparse and thsr:query-lookup/thsr:expand
Developer Forum,
I am looking to expand our users’ queries using a thesaurus. We are using search:search with an extensive options node. I am looking to avoid having to recreate all parsing structures using string processing. Although string-join may work for simple queries, it becomes considerably more difficult when contending with nested sets (parenthesis), phrases (quotes, beginning and ending), and Boolean/other operators. Subsequently, I was hoping to use search:parse -> thsr:expand/thsr:query-lookup -> search:unparse. However, I am running into mixed-content type and annotation errors. This is basically what I am trying to do:
let $q := <q>"tile drainage" AND (phosphorous OR nitrogen)</q>
let $qparsed := search:parse($q,$OPTIONS)
let $qexpanded := thsr:query-lookup("/myThsrDocs/NALT3.xml",$qparsed)
let $qout := search:unparse(search:parse($qexpanded,$OPTIONS))
return $qout
Is there a way to do this?
So you don’t have to see our options node, $qparsed equals
'
<cts:and-query qtextjoin="AND" strength="20" xmlns:cts="http://marklogic.com/cts">
<cts:word-query qtextpre=""" qtextref="cts:text" qtextpost=""">
<cts:text>tile drainage</cts:text>
<cts:option>punctuation-sensitive</cts:option>
<cts:option>case-insensitive</cts:option>
<cts:option>wildcarded</cts:option>
</cts:word-query>
<cts:or-query qtextjoin="OR" strength="10">
<cts:word-query qtextref="cts:text">
<cts:text>phosphorous</cts:text>
<cts:option>punctuation-sensitive</cts:option>
<cts:option>case-insensitive</cts:option>
<cts:option>wildcarded</cts:option>
</cts:word-query>
<cts:word-query qtextref="cts:text">
<cts:text>nitrogen</cts:text>
<cts:option>punctuation-sensitive</cts:option>
<cts:option>case-insensitive</cts:option>
<cts:option>wildcarded</cts:option>
</cts:word-query>
</cts:or-query>
</cts:and-query>
'
Thank you,
Matthew
______________________________________
Matthew Treskon
Digital Services Librarian--DigiTop
National Agricultural Library
US Department of Agriculture, ARS
matthew.treskon at ars.usda.gov<mailto:matthew.treskon at ars.usda.gov>
765-494-8692 (Phone)
765-494-1705 (Fax)
...advancing access to global
information for agriculture.
______________________________________
This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://community.marklogic.com/pipermail/general/attachments/20120622/85f58ae2/attachment-0001.html
More information about the General
mailing list