xquery - Numbers in cts:word query in Marklogic -
i have cts:word-query having number text value. cts:search(fn:doc(),cts:word-query("226"))
this query fetch results matching 226 in documents. need documents contain 0026 also.
example: abc.xml
<a> <b>00226</b> </a> this abc1.xml
<a> <b>226</b> </a> if give query cts:search(fn:doc(),cts:word-query("226")), fetch abc1.xml , if query cts:search(fn:doc(),cts:word-query("00226")), fetch abc.xml.
but need both documents, irrespective of leading zeros.
simplest way use wild card character (*) , add wildcarded option
cts:search(fn:doc(),cts:word-query("*226", ('wildcarded'))) edit:
although matches example documents, kishan points out in comments, the wildcard matches unwanted documents (e.g. containing "226226").
since range indexes not option in case because data mixed, here alternative hack:
cts:search( fn:doc(), cts:word-query( $lead in ('', '0', '00', '000') return $lead || "226")) obviously, depends on how many leading zeros there can , work if known , limited.
Comments
Post a Comment