We need to achieve the wildcarded searches with both the characters "*" and "?" as described in
https://docs.marklogic.com/10.0/guide/search-dev/wildcard
Wildcard Characters
Marklogic Server supports two wildcard characters: * and ?.
- matches zero or more non-space characters.
? matches exactly one non-space character.
For example, he* will match any word starting with he, such as he, her, help, hello, helicopter, and so on. On the other hand, he? will only match three-letter words starting with he, such as hem, hen, and so on.
But we do the search as below,
let $options := <options xmlns="http://marklogic.com/appservices/search">
<constraint name="DocumentTitle">
<word type="xs:string" facet="false">
<element ns="http://marklogic.com/nondeliverable" name="DocumentTitle"/>
<search:term-option>wildcarded</search:term-option>,
<search:term-option>case-insensitive</search:term-option>,
<search:term-option>diacritic-insensitive</search:term-option>,
<search:term-option>unstemmed</search:term-option>
</word>
</constraint>
<return-query>true</return-query>
<return-qtext>true</return-qtext>
<return-metrics>true</return-metrics>
</options>
return (search:search("(DocumentTitle:(medi*ation))",$options,1,10),search:search("(DocumentTitle:(medi?ation))",$options,1,10))
Both the search queries are returning same count. But if we do the search
cts:search(fn:doc(),cts:element-word-query(xs:QName("nd:DocumentTitle"),"medi?ation",("wildcarded"))),cts:search(fn:doc(),cts:element-word-query(xs:QName("nd:DocumentTitle"),"medi*ation",("wildcarded")))
the count are different and returning the proper result.
How we can achieve wildcarded searches with both the characters "*" and "?" in search:search with proper result.
question from:
https://stackoverflow.com/questions/65919615/wildcarded-search-with-and-in-searchsearch-not-working-properly 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…