Hi Gary,

I think for cts:element-value-query, you can do a starts-with by taking the 
string the user gives and appending "* *" to it.  This is because, for values, 
* by itself matches can span tokens.  For example, this query returns true:

let $x := <foo><a>this is a value</a></foo>
return
cts:contains($x,
  cts:element-value-query(xs:QName("a"), "t* *", "wildcarded") )

I'd have to scratch my head a little for a contains with element-value-query, 
but I think you can do something similar and it could work.  Something like 
this for "is a v":

let $x := <foo><a>this is a value</a></foo>
return
cts:contains($x,
  cts:element-value-query(xs:QName("a"), "* *is a v* *", "wildcarded") )

So in this case, you prepend and append a "* *" to the string the user 
supplies.  I am not positive I have thought this one through though, although 
it seems to work in the simple case.

-Danny

From: [email protected] 
[mailto:[email protected]] On Behalf Of Gary Larsen
Sent: Friday, June 24, 2011 11:18 AM
To: 'General MarkLogic Developer Discussion'
Subject: Re: [MarkLogic Dev General] wildcarding in constraining query

Hi Gajanan,

Thanks for the suggestions.  cts:field-word-query() is producing accurate 
results as a 'contains' query, using a '*value*' matcher.  Having a 
'starts-with' query would be a nice to have feature in my application but not 
critical.

gary


From: [email protected] 
[mailto:[email protected]] On Behalf Of Gajanan 
Chinchwadkar
Sent: Friday, June 24, 2011 1:19 PM
To: General MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] wildcarding in constraining query

Have you looked at cts:word-query with phrase-through/phrase-around?

If you want to look at particular elements, you can also define a field on 
these elements and cts:use field-word-query.

Thanks,

Gajanan

From: [email protected] 
[mailto:[email protected]] On Behalf Of Gary Larsen
Sent: Friday, June 24, 2011 9:36 AM
To: 'General MarkLogic Developer Discussion'
Subject: [MarkLogic Dev General] wildcarding in constraining query

I'm attempting to create both 'starts-with' and 'contains' queries (for a 
constraining query) on element values which needs to work across word 
boundaries.

cts:element-value-query() does not wildcard across word boundaries and  
cts:element-word query() only matches on single words.  cts:element-value-match 
does what I need but does not return a cts:query.   Are there any other options 
I have not looked at?

Thanks,
gary





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

Reply via email to