The only workaround using the int index that I could think of would be to use ranges with range-queries. Something like:
let $pattern := 200 return cts:or-query(( for $i in 0 to 10 let $power := xs:int(math:pow(10, $i)) let $start := $pattern * $power let $end := ($pattern + 1) * $power return cts:and-query(( cts:element-range-query(xs:QName("element"), ">=", $start), cts:element-range-query(xs:QName("element"), "<", $end) )) )) Cheers From: <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>> on behalf of Evan Lenz <e...@lenzconsulting.com<mailto:e...@lenzconsulting.com>> Reply-To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Date: Monday, June 19, 2017 at 11:29 PM To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Subject: Re: [MarkLogic Dev General] cts:element-value-match for integers Hi Oleksii, You'll have to create a string range index too. I've never used cts:element-value-match() with anything but a string index, but it looks like it's possible: you just get back the value you asked for, if it exists. And now that I think about it, that can be rather useful! So thanks for effectively cluing me in to this use case! :-) The docs for the $pattern parameter say: "The parameter type must match the lexicon type. String parameters may include wildcard characters."[1] So that seems to confirm that wildcards can only be used with string-typed range indexes. Evan [1] http://docs.marklogic.com/cts:element-value-match#pattern Evan Lenz President, Lenz Consulting Group, Inc. http://lenzconsulting.com +1 (206) 898-1654 On Mon, Jun 19, 2017 at 12:23 PM, Oleksii Segeda <oseg...@worldbankgroup.org<mailto:oseg...@worldbankgroup.org>> wrote: Christopher, It gives false positives if I use it with cts:element-values. Shan, The rule is to find all values which start with given value. For example, 200 should match 200, 2001, 2002, ... 20010, 20020, 2002123, etc.. Are you suggesting to guess all possible combinations? If so, it's not possible. As I said, I need something like this (pseudo code): cts:element-value-match(xs:QName("element"), "200*") except that I don't have a string range index on that field, but I do have an int range index instead. Best, Oleksii. -----Original Message----- From: general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com> [mailto:general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>] On Behalf Of Shan Jiang Sent: Monday, June 19, 2017 2:06 PM To: MarkLogic Developer Discussion <general@developer.marklogic.com<mailto:general@developer.marklogic.com>> Subject: Re: [MarkLogic Dev General] cts:element-value-match for integers What is your exact search rule? From your example, looks like you try to look for another number by adding a ³0². If that is the case, can you run a cts:or-query, one for 200, and one for 2000? Shan Jiang Principal Consultant MarkLogic Corporation shan.ji...@marklogic.com<mailto:shan.ji...@marklogic.com> Phone: +1 703 869 4672<tel:%2B1%20703%20869%204672> www.marklogic.com<http://www.marklogic.com> <http://www.marklogic.com/> On 6/19/17, 12:59 PM, "general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com> on behalf of Oleksii Segeda" <general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com> on behalf of oseg...@worldbankgroup.org<mailto:oseg...@worldbankgroup.org>> wrote: >Hi everyone, > >Any thoughts on this? > >Oleksii. > > >-----Original Message----- >From: Oleksii Segeda >Sent: Friday, June 16, 2017 6:16 PM >To: general@developer.marklogic.com<mailto:general@developer.marklogic.com> >Subject: cts:element-value-match for integers > >Hi everyone, > >Can someone explain how does cts:element-value-match work with integer >indexes? I cannot pass a string as a second argument, so it's unclear how >to do a wildcarded search. >Ultimate goal is to find 2000 and 200, if user typed 200. I understand >that I can create an additional string index, but I want to know if a >better solution exists. > >Thanks. > >Oleksii Segeda >IT Analyst >Information and Technology Solutions >www.worldbank.org<http://www.worldbank.org> > > > > >_______________________________________________ >General mailing list >General@developer.marklogic.com<mailto:General@developer.marklogic.com> >Manage your subscription at: >http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list General@developer.marklogic.com<mailto:General@developer.marklogic.com> Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list General@developer.marklogic.com<mailto:General@developer.marklogic.com> Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list General@developer.marklogic.com Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general