Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It looks odd to me too, using 4.2-6 on OS X. Here's what the results looked like in my test, using the full oscars data set.</p> <pre><code>import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy"; let $options := &lt;options xmlns="http://marklogic.com/appservices/search"&gt; &lt;default-suggestion-source&gt; &lt;range type="xs:string"&gt; &lt;element ns="http://marklogic.com/wikipedia" name="name" /&gt; &lt;/range&gt; &lt;/default-suggestion-source&gt; &lt;/options&gt; return search:suggest("Robert Lo", $options) =&gt; Robert "Loretta Young" Robert "Lorraine Bracco" Robert "Lotte Lenya" Robert "Louis Calhern" Robert "Louis Gossett, Jr." Robert "Louis Malle" Robert "Louise Fletcher" </code></pre> <p>It looks like the values are generated for or-query(('Robert', 'Lo')) and then merged in an odd way. If we drop down to using the cts lexicon function, things look normal.</p> <pre><code>cts:element-value-match( QName('http://marklogic.com/wikipedia', 'name'), 'Robert Lo*') =&gt; Robert Loggia </code></pre> <p>The word-swap aspect makes things more complicated, and goes beyond the scope of what autosuggest usually does (and what <code>search:suggest</code> and <code>cts:element-value-match</code> can do without help).</p> <p>Here's a version that uses extra string manipulation to create two patterns, handling pairs of words. It assumes that the first word is always complete, while the second might be a stub, but that the words may need to be swapped for a match. If you define your desired logic, you should be able to modify this to suit your requirements. Note that function mapping is in play, so <code>cts:element-value-match</code> is called once per pattern during evaluation. That may have a performance impact.</p> <pre><code>let $toks := cts:tokenize($INPUT)[. instance of cts:word] let $pat := ( if (count($toks) eq 1) then concat($toks, '*') else ( concat($toks[2], '* ', $toks[1]), concat($toks[1], ' ', $toks[2], '*'))) return cts:element-value-match( QName('http://marklogic.com/wikipedia', 'name'), $pat) =&gt; Robert Loggia </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload