title: cts:search is returning unexpected results for unfiltered search option when wildcard is enabled
body: <p>I am performing <strong>cts:search</strong> with <strong>"unfiltered"</strong> option and wildcard search is enabled (means passing <strong>"wildcarded"</strong>).</p>
  
  <p>In my database, I have inserted 5 xml documents which I have pasted below.</p>
  
  <p>In the below cts:query if the value of <strong>journalTitle</strong> element contains a <strong>wildcard(*)</strong> it's returning me all the 5 documents.</p>
  
  <p>for example: "d*", "di*", "dixi*"</p>
  
  <p>Even if I am passing <strong>"mohi*t"</strong> as a value for <strong>journalTitle</strong> element, I am getting all the five documents in the result.</p>
  
  <p>For <strong>"filtered"</strong> option it is working fine.</p>
  
  <p>I am curious about why this behaviour? and please also let me know how can I correct this for <strong>"unfiltered"</strong> option.</p>
  
  <p>I have searched a lot on google regarding this but did not find the solution.</p>
  
  <p>Please find below the cts:search query and xml files</p>
  
  <p><strong>cts:query</strong></p>
  
  <pre><code>cts:search(fn:collection(), cts:element-query(
          xs:QName("root"), 
          cts:and-query(
            (
              cts:element-value-query(xs:QName("sourceType"), "JA", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1), 
              cts:element-value-query(xs:QName("journalTitle"), "mohi*t", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1), 
              cts:element-value-query(xs:QName("title"), "title1", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1), 
              cts:element-value-query(xs:QName("volume"), "volume0", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1)
            ), 
            ()
          ), 
          ()
         ),"unfiltered")
  </code></pre>
  
  <p><strong>XML content - pasted all the five xmls:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;root&gt;
      &lt;journalTitle&gt;Dinesh&lt;/journalTitle&gt;
      &lt;sourceType&gt;JA&lt;/sourceType&gt;
      &lt;title&gt;title1&lt;/title&gt;
      &lt;volume&gt;volume0&lt;/volume&gt;
  &lt;/root&gt;
  -
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;root&gt;
      &lt;journalTitle&gt;Dixit&lt;/journalTitle&gt;
      &lt;sourceType&gt;JA&lt;/sourceType&gt;
      &lt;title&gt;title1&lt;/title&gt;
      &lt;volume&gt;volume0&lt;/volume&gt;
  &lt;/root&gt;
  -
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;root&gt;
      &lt;journalTitle&gt;Prashant&lt;/journalTitle&gt;
      &lt;sourceType&gt;JA&lt;/sourceType&gt;
      &lt;title&gt;title1&lt;/title&gt;
      &lt;volume&gt;volume0&lt;/volume&gt;
  &lt;/root&gt;
  -
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;root&gt;
      &lt;journalTitle&gt;GAYARI&lt;/journalTitle&gt;
      &lt;sourceType&gt;JA&lt;/sourceType&gt;
      &lt;title&gt;title1&lt;/title&gt;
      &lt;volume&gt;volume0&lt;/volume&gt;
  &lt;/root&gt;
  -
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;root&gt;
      &lt;journalTitle&gt;KEVAL&lt;/journalTitle&gt;
      &lt;sourceType&gt;JA&lt;/sourceType&gt;
      &lt;title&gt;title1&lt;/title&gt;
      &lt;volume&gt;volume0&lt;/volume&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>You might need the xdmp:plan result so I have pasted it below</p>
  
  <p><strong>xdmp:plan result:</strong></p>
  
  <pre><code>&lt;qry:query-plan xmlns:qry="http://marklogic.com/cts/query"&gt;
      &lt;qry:info-trace&gt;xdmp:eval("xdmp:plan(cts:search(fn:collection(), cts:element-query(&amp;amp;#10;   ...", (), &amp;lt;options xmlns="xdmp:eval"&amp;gt;&amp;lt;database&amp;gt;12874763000056740838&amp;lt;/database&amp;gt;&amp;lt;root&amp;gt;C:\RSuite\modules...&amp;lt;/options&amp;gt;)&lt;/qry:info-trace&gt;
      &lt;qry:info-trace&gt;Analyzing path for search: fn:collection()&lt;/qry:info-trace&gt;
      &lt;qry:info-trace&gt;Step 1 is searchable: fn:collection()&lt;/qry:info-trace&gt;
      &lt;qry:info-trace&gt;Path is fully searchable.&lt;/qry:info-trace&gt;
      &lt;qry:info-trace&gt;Gathering constraints.&lt;/qry:info-trace&gt;
      &lt;qry:info-trace&gt;Search query contributed 1 constraint: cts:element-query(fn:QName("", "root"), cts:and-query((cts:element-value-query(fn:QName("", "sourceType"), "JA", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1), cts:element-value-query(fn:QName("", "journalTitle"), "mohi*t", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1), cts:element-value-query(fn:QName("", "title"), "title1", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1), cts:element-value-query(fn:QName("", "volume"), "volume0", ("case-insensitive","diacritic-sensitive","punctuation-sensitive","whitespace-sensitive","wildcarded","lang=en"), 1)), ()), ())&lt;/qry:info-trace&gt;
      &lt;qry:partial-plan&gt;
          &lt;qry:or-two-queries&gt;
              &lt;qry:element-query&gt;
                  &lt;qry:key&gt;10866465315185201428&lt;/qry:key&gt;
                  &lt;qry:annotation&gt;element(root)&lt;/qry:annotation&gt;
                  &lt;qry:and-query&gt;
                      &lt;qry:term-query weight="1"&gt;
                          &lt;qry:key&gt;15329831187071590131&lt;/qry:key&gt;
                          &lt;qry:annotation&gt;element(sourceType,value("JA"))&lt;/qry:annotation&gt;
                      &lt;/qry:term-query&gt;
                      &lt;qry:term-query weight="0"&gt;
                          &lt;qry:key&gt;3029765743981997321&lt;/qry:key&gt;
                          &lt;qry:annotation&gt;element(journalTitle)&lt;/qry:annotation&gt;
                      &lt;/qry:term-query&gt;
                      &lt;qry:term-query weight="1"&gt;
                          &lt;qry:key&gt;4206353216190327061&lt;/qry:key&gt;
                          &lt;qry:annotation&gt;element(title,value("title1"))&lt;/qry:annotation&gt;
                      &lt;/qry:term-query&gt;
                      &lt;qry:term-query weight="1"&gt;
                          &lt;qry:key&gt;7729558342335907080&lt;/qry:key&gt;
                          &lt;qry:annotation&gt;element(volume,value("volume0"))&lt;/qry:annotation&gt;
                      &lt;/qry:term-query&gt;
                  &lt;/qry:and-query&gt;
              &lt;/qry:element-query&gt;
              &lt;qry:and-two-queries&gt;
                  &lt;qry:term-query weight="0"&gt;
                      &lt;qry:key&gt;837267169796541076&lt;/qry:key&gt;
                      &lt;qry:annotation&gt;link-child(descendant(element(root)))&lt;/qry:annotation&gt;
                  &lt;/qry:term-query&gt;
                  &lt;qry:and-query&gt;
                      &lt;qry:term-query weight="1"&gt;
                          &lt;qry:key&gt;15329831187071590131&lt;/qry:key&gt;
                          &lt;qry:annotation&gt;element(sourceType,value("JA"))&lt;/qry:annotation&gt;
                      &lt;/qry:term-query&gt;
                      &lt;qry:term-query weight="0"&gt;
                          &lt;qry:key&gt;3029765743981997321&lt;/qry:key&gt;
                          &lt;qry:annotation&gt;element(journalTitle)&lt;/qry:annotation&gt;
                      &lt;/qry:term-query&gt;
                      &lt;qry:term-query weight="1"&gt;
                          &lt;qry:key&gt;4206353216190327061&lt;/qry:key&gt;
                          &lt;qry:annotation&gt;element(title,value("title1"))&lt;/qry:annotation&gt;
                      &lt;/qry:term-query&gt;
                      &lt;qry:term-query weight="1"&gt;
                          &lt;qry:key&gt;7729558342335907080&lt;/qry:key&gt;
                          &lt;qry:annotation&gt;element(volume,value("volume0"))&lt;/qry:annotation&gt;
                      &lt;/qry:term-query&gt;
                  &lt;/qry:and-query&gt;
              &lt;/qry:and-two-queries&gt;
          &lt;/qry:or-two-queries&gt;
      &lt;/qry:partial-plan&gt;
      &lt;qry:info-trace&gt;Executing search.&lt;/qry:info-trace&gt;
      &lt;qry:final-plan&gt;
          &lt;qry:and-query&gt;
              &lt;qry:or-two-queries&gt;
                  &lt;qry:element-query&gt;
                      &lt;qry:key&gt;10866465315185201428&lt;/qry:key&gt;
                      &lt;qry:annotation&gt;element(root)&lt;/qry:annotation&gt;
                      &lt;qry:and-query&gt;
                          &lt;qry:term-query weight="1"&gt;
                              &lt;qry:key&gt;15329831187071590131&lt;/qry:key&gt;
                              &lt;qry:annotation&gt;element(sourceType,value("JA"))&lt;/qry:annotation&gt;
                          &lt;/qry:term-query&gt;
                          &lt;qry:term-query weight="0"&gt;
                              &lt;qry:key&gt;3029765743981997321&lt;/qry:key&gt;
                              &lt;qry:annotation&gt;element(journalTitle)&lt;/qry:annotation&gt;
                          &lt;/qry:term-query&gt;
                          &lt;qry:term-query weight="1"&gt;
                              &lt;qry:key&gt;4206353216190327061&lt;/qry:key&gt;
                              &lt;qry:annotation&gt;element(title,value("title1"))&lt;/qry:annotation&gt;
                          &lt;/qry:term-query&gt;
                          &lt;qry:term-query weight="1"&gt;
                              &lt;qry:key&gt;7729558342335907080&lt;/qry:key&gt;
                              &lt;qry:annotation&gt;element(volume,value("volume0"))&lt;/qry:annotation&gt;
                          &lt;/qry:term-query&gt;
                      &lt;/qry:and-query&gt;
                  &lt;/qry:element-query&gt;
                  &lt;qry:and-two-queries&gt;
                      &lt;qry:term-query weight="0"&gt;
                          &lt;qry:key&gt;837267169796541076&lt;/qry:key&gt;
                          &lt;qry:annotation&gt;link-child(descendant(element(root)))&lt;/qry:annotation&gt;
                      &lt;/qry:term-query&gt;
                      &lt;qry:and-query&gt;
                          &lt;qry:term-query weight="1"&gt;
                              &lt;qry:key&gt;15329831187071590131&lt;/qry:key&gt;
                              &lt;qry:annotation&gt;element(sourceType,value("JA"))&lt;/qry:annotation&gt;
                          &lt;/qry:term-query&gt;
                          &lt;qry:term-query weight="0"&gt;
                              &lt;qry:key&gt;3029765743981997321&lt;/qry:key&gt;
                              &lt;qry:annotation&gt;element(journalTitle)&lt;/qry:annotation&gt;
                          &lt;/qry:term-query&gt;
                          &lt;qry:term-query weight="1"&gt;
                              &lt;qry:key&gt;4206353216190327061&lt;/qry:key&gt;
                              &lt;qry:annotation&gt;element(title,value("title1"))&lt;/qry:annotation&gt;
                          &lt;/qry:term-query&gt;
                          &lt;qry:term-query weight="1"&gt;
                              &lt;qry:key&gt;7729558342335907080&lt;/qry:key&gt;
                              &lt;qry:annotation&gt;element(volume,value("volume0"))&lt;/qry:annotation&gt;
                          &lt;/qry:term-query&gt;
                      &lt;/qry:and-query&gt;
                  &lt;/qry:and-two-queries&gt;
              &lt;/qry:or-two-queries&gt;
          &lt;/qry:and-query&gt;
      &lt;/qry:final-plan&gt;
      &lt;qry:info-trace&gt;Selected 5 fragments&lt;/qry:info-trace&gt;
      &lt;qry:result estimate="5"/&gt;
  &lt;/qry:query-plan&gt;
  </code></pre>
  
  <p>Apology if there is any gramatical error.</p>
  
  <p>If you need more info please let me know.</p>