Dear Selven:

Here's a debugging tip:  check your options node using search:check-options().  
If you do search:check-options($options) on your options node, you'll get a 
report that looks like:

<search:report id="SEARCH-SCHEMAINVALID" 
xmlns:search="http://marklogic.com/appservices/search";><error:format-string 
xmlns:error="http://marklogic.com/xdmp/error";>XDMP-VALIDATEUNEXPECTED: 
(err:XQDY0027) validate strict { $opt } -- Invalid node: Found @name but 
expected (@ref) at /search:options/search:suggestion-source/@name using schema 
"search.xsd"</error:format-string><error:data 
xmlns:error="http://marklogic.com/xdmp/error";>
    <error:datum>@name</error:datum>
    <error:datum>(@ref)</error:datum>
    <error:datum>/search:options/search:suggestion-source/@name</error:datum>
    <error:datum>"search.xsd"</error:datum>
  </error:data></search:report>

This points you to the first problem, which is that  <suggestion-source 
name="tag"> should be  <suggestion-source ref="tag">.

(If you run search:check-options($options,true()) it runs in strict mode, which 
also checks for missing indexes.)

The reason you're getting the error on queries with "tag:" is that the API is 
trying to provide constrained suggestions for the terms starting with "tag:" 
(suggestions limited just as queries with that constraint would be limited).  
It doesn't see an alternate suggestion source with @ref="tag", so it tries to 
use the range index specified for the constraint.  The constraint definition is 
missing the collation attribute, and the query appears to be defaulting to 
codepoint collation when one isn't specified.    

If you change @name to @ref on your suggestion source element, the API will use 
the range index specified in the <suggestion-source> element.  If you don't do 
that, but do add the @collation to your constraint, the suggestions will come 
from the chapter element rather than the title.

--Colleen
________________________________________
From: [email protected] 
[[email protected]] On Behalf Of Selven Xavier 
[[email protected]]
Sent: Thursday, September 03, 2009 6:59 AM
To: [email protected]
Subject: [MarkLogic Dev General] Problem with search:suggest

Hi Team,
While analyzing on “search:suggest” API we were not able to understand the 
following feature in detail:

xquery version "1.0-ml";
import module namespace search =
"http://marklogic.com/appservices/search";
at "/MarkLogic/appservices/search/search.xqy";

let $options :=
<options xmlns="http://marklogic.com/appservices/search";>
 <constraint name="tag">
   <range
          type="xs:string" facet="true">
      <element ns="http://www.simonandschuster.com/namespaces/sands_pub";
               name="chapter"/>
   </range>
 </constraint>
 <suggestion-source name="tag">
     <range collation="http://marklogic.com/collation";
          type="xs:string" facet="true">
      <element ns="http://www.simonandschuster.com/namespaces/sands_pub";
               name="title"/>
   </range>
 </suggestion-source>
</options>
return
search:suggest(("tag:A","tag:B"), $options,(),5,2)

We have created 2 element range index (title, chapter) through admin screen. 
When we try to run the above snippet, we are getting following error

[1.0-ml] XDMP-ELEMRIDXNOTFOUND: 
cts:element-value-match(QName("http://www.simonandschuster.com/namespaces/sands_pub";,
 "chapter"), "B*", ("type=string", "document"), 
cts:element-range-query(QName("http://www.simonandschuster.com/namespaces/sands_pub";,
 "chapter"), "=", "A", ("collation=http://marklogic.com/collation/codepoint";), 
1), xs:double("1"), ()) -- No string element range index for 
QName("http://www.simonandschuster.com/namespaces/sands_pub";, "chapter") 
http://marklogic.com/collation/codepoint


When we try to run the above code with “titlelist” or some other word instead 
of tag in the entire name attribute, we are able to execute the code without 
error. Can anyone help us to clearly understand the search:suggest feature with 
all the available option.
Thanks in Advance.


Regards,
Selven Xavier.A
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to