Hi, Blessing:

A couple of issues:

*  Term options are only valid for term, word, and value queries.  If you add 
<debug>true</debug> to the options, you'll see that the Search API is dropping 
the term options.

*  I think you probably want a word constraint on an element rather than an 
element query.  An element query specifies an element container for nested 
queries scoped to that element.

With a suitable database configuration, the following worked for me:

let $QUERY-OPTIONS := (<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>
                       )
let $OPTIONS := <options xmlns="http://marklogic.com/appservices/search";>
                               <constraint name="Author">
                                 <word>
                                 <element ns="" name="Author"/>
                                  {$QUERY-OPTIONS}
                                 </word>
                              </constraint>
                              <page-length>1000</page-length>
                              <debug>true</debug>
                </options>
let $query := "Author:Peter*"
return search:search($query,$OPTIONS)


Hoping that's useful,


Erik Hennum

________________________________
From: [email protected] 
[[email protected]] on behalf of Blessing N 
[[email protected]]
Sent: Friday, September 27, 2013 12:56 AM
To: [email protected]
Subject: [MarkLogic Dev General] Issue with Wildcard search in cts:element-query

Hi,

I have records as follows

<record>
<Author>
<Name>Peter</Name>
<City>NewYork</City>
</Author>
<Editor>
<Name>Steven</Name>
<City>Virginia</City>
</Editor>
</record>

<record>
<Author>
<Name>Smith</Name>
<City>Phoenix</City>
</Author>
<Editor>
<Name>Peter Jackson</Name>
<City>Washington</City>
</Editor>
</record>

My requirement is to find Author/Name starting with  "Peter*" which should 
return only the first record. However the following code returns  both the 
record where "Peter*" is present in Editor/Name


declare variable $mynamespace := "http://some.com/mynamespace";;
declare variable $QUERY-OPTIONS := 
(<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>
                                    );

declare variable $OPTIONS := <options 
xmlns="http://marklogic.com/appservices/search";>
                               <constraint name="Author">
                                 <element-query ns="{$mynamespace}" 
name="Author" />
                                  {$QUERY-OPTIONS}
                              </constraint>,
                              <page-length>1000</page-length>,

                                                                             
</options>;
let $query := "Author:Peter*"
let $results := search:search($query,$OPTIONS)
return $results

This is the query formed

<search:report id="SEARCH-FLWOR">(cts:search(fn:collection(), 
cts:element-query(xs:QName("mynamespace:Author"), cts:word-query("Peter*", 
("lang=en"), 1), ()), ("score-logtfidf"), 1))[1 to 1000]</search:report>

I found this issue only with Wildcard search in cts:element-query whereas 
"Author:Peter" works perfectly. Is this a known issue or do i have to modify my 
implementation.

Thanks





_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to