Hi,

I need to build a dynamic OR query

Let's say my search term is "code of conduct" so output should be

<cts:or-query>
                        <cts:word-query>
                          <cts:text>Code</cts:text>
                          <cts:option>case-insensitive</cts:option>
                          <cts:option>wildcarded</cts:option>
                        </cts:word-query>

                        <cts:word-query>
                          <cts:text>of</cts:text>
                          <cts:option>case-insensitive</cts:option>
                          <cts:option>wildcarded</cts:option>
                        </cts:word-query>

                        <cts:word-query>
                          <cts:text>Conduct</cts:text>
                          <cts:option>case-insensitive</cts:option>
                          <cts:option>wildcarded</cts:option>
                        </cts:word-query>

<cts:word-query>
<cts:text xml:lang="en">code of conduct</cts:text>
<cts:option>case-insensitive</cts:option>
</cts:word-query>

</cts:or-query>

When I trying

let $searchterm := "code of conduct"
let $query :=cts:or-query((cts:word-query(fn:string-join($searchterm," "), 
"case-insensitive"),
    cts:word-query($searchterm, "case-insensitive")))
return $query

<cts:or-query>
<cts:word-query>
<cts:text xml:lang="en">code of conduct</cts:text>
<cts:option>case-insensitive</cts:option>
</cts:word-query>

<cts:word-query>
<cts:text xml:lang="en">code of conduct</cts:text>
<cts:option>case-insensitive</cts:option>
</cts:word-query>
</cts:or-query>


I understand we should tokenize with " "and build the query, but we can't 
update variables in XQUERY right, that's why was wondering how to reach the 
solution


~Gurbeer



--------------------------------------------------------------------------
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or 
views contained herein are not intended to be, and do not constitute, advice 
within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and 
Consumer Protection Act. If you have received this communication in error, 
please destroy all electronic and paper copies and notify the sender 
immediately. Mistransmission is not intended to waive confidentiality or 
privilege. Morgan Stanley reserves the right, to the extent permitted under 
applicable law, to monitor electronic communications. This message is subject 
to terms available at the following link: 
http://www.morganstanley.com/disclaimers. If you cannot access these links, 
please notify us by reply message and we will send the contents to you. By 
messaging with Morgan Stanley you consent to the foregoing.
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to