Hi Mano,

In your original email, you say you need to display a list of names that match 
a pattern.  Similar to Szabolcs' suggestion of using a range query, you can use 
the lexicon functions which just return the values from the range index.  And 
range indexes are fast.  cts:element-value-match is probably what you want.  
Something like:

cts:element-value-match("xs:QName("Surname"), "J*")

You can also pass this a cts:query if you want to constrain the lexicon look-up 
to fragments that match a query.

You should only need to use cts:search if you want your results in relevance 
order.

Hope that helps,
-Danny

From: [email protected] 
[mailto:[email protected]] On Behalf Of Illes, Szabolcs
Sent: Thursday, February 10, 2011 7:47 AM
To: General MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Alternate for wildcard search

Hi,

What about using element-range-query, like:

cts:search( fn:collection("UserDetails")//User,
  cts:and-query((
    cts:element-range-query(xs:QName(" Surname"),">=","S"),
    cts:element-range-query(xs:QName(" Surname"),"<","T")
  ))
)

You need to setup a string range index on Surname

Szabolcs




On 10/02/2011 11:25, "Geert Josten" <[email protected]> wrote:
Hi Mano,

You could do fn:collection("UserDetails")//User//Surname[fn:starts-with('J', 
.)], but I don't really expect that to be faster than using the wildcard option 
of the query. Could even be that above expression is optimized to your query.

Kind regards,
Geert


Van: [email protected] 
[mailto:[email protected]] Namens mano m
Verzonden: donderdag 10 februari 2011 11:44
Aan: [email protected]
Onderwerp: [MarkLogic Dev General] Alternate for wildcard search


Hi,



In my application I have to display the list user name starts with the 
character choosen by the User. In the ML database all the Wildcard options are 
disabled. I have enabled the Wildcard in cts:element-word-query() directly , 
which slow down the query execution. Is there anyother way to get the user 
names starts with specific character?



Sample query:

cts:search (fn:collection("UserDetails")//User,
                 cts:element-word-query(xs:QName ("Surname"),"J*", 
"wildcarded"))



Regards,

Mano


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

********************************************************************************
DISCLAIMER: This e-mail is confidential and should not be used by anyone who is
not the original intended recipient. If you have received this e-mail in error
please inform the sender and delete it from your mailbox or any other storage
mechanism. Neither Macmillan Publishers Limited nor any of its agents accept
liability for any statements made which are clearly the sender's own and not
expressly made on behalf of Macmillan Publishers Limited or one of its agents.
Please note that neither Macmillan Publishers Limited nor any of its agents
accept any responsibility for viruses that may be contained in this e-mail or
its attachments and it is your responsibility to scan the e-mail and
attachments (if any). No contracts may be concluded on behalf of Macmillan
Publishers Limited or its agents by means of e-mail communication. Macmillan
Publishers Limited Registered in England and Wales with registered number 785998
Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS
********************************************************************************
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to