I couldn't say if that's a bug in your options or somewhere in search.xqy, but 
I thought I'd pass along a debugging tip. Call search:parse so you can see the 
query that is generated - and so other folks can reproduce the problem. It's 
also a good idea to verify your options using search:check-options and the 
strict option: yours seem to be ok.

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="title">
     <word>
       <element ns="http://digital.library.ptsem.edu/ia"; name="title"/>
     </word>
   </constraint>
   <term>
     <default ref="title"/>
   </term>
 </options>
return (
  search:check-options($options, true()),
  search:parse('"king james" OR authorized', $options))

=>
<cts:or-query qtextjoin="OR" strength="10" qtextgroup="( )" 
xmlns:cts="http://marklogic.com/cts"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
  <cts:word-query qtextpre="&quot;" qtextref="cts:text" qtextpost="&quot;">
    <cts:text>king james</cts:text>
  </cts:word-query>
  <cts:element-word-query qtextref="cts:text">
    <cts:element 
xmlns:_1="http://digital.library.ptsem.edu/ia";>_1:title</cts:element>
    <cts:text>authorized</cts:text>
  </cts:element-word-query>
</cts:or-query>

This makes it obvious that the resulting query is not what you want: "king 
james" term is a simple word-query term, and the "authorized" term is an 
element-word-query term. 

-- Mike

On 9 Dec 2013, at 09:47 , Murray, Gregory <[email protected]> wrote:

> After further experimentation, I am finding that <default> doesn't work as I 
> would expect when an exact phrase is involved. For example, I was expecting 
> this query:
> 
> 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="title">
>      <word>
>        <element ns="http://digital.library.ptsem.edu/ia"; name="title"/>
>      </word>
>    </constraint>
>    <term>
>      <default ref="title"/>
>    </term>
>  </options>
> return search:search('"king james" OR authorized', $options)
> 
> to return the same results as this query:
> 
> 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="title">
>      <word>
>        <element ns="http://digital.library.ptsem.edu/ia"; name="title"/>
>      </word>
>    </constraint>
>  </options>
> return search:search('title:"king james" OR title:authorized', $options)
> 
> Not so! Instead, query #1 returns the same results as taking query #2 and 
> changing title:"king james" to "king james" -- which clearly indicates that 
> the <default> option is NOT applying the "title" constraint to quoted/exact 
> phrases.
> 
> Could this be a bug? The documentation for search:search, in the description 
> of <term>, says that <default> "determines special handling to all terms". In 
> my mind, an exact phrase *is* a term, and therefore the <default> constraint 
> should be applied to exact phrases -- or am I misunderstanding what a "term" 
> is?
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to