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:
<[email protected]<mailto:[email protected]>>
on behalf of Evan Lenz
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Date: Monday, June 19, 2017 at 11:29 PM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
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
<[email protected]<mailto:[email protected]>> 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:
[email protected]<mailto:[email protected]>
[mailto:[email protected]<mailto:[email protected]>]
On Behalf Of Shan Jiang
Sent: Monday, June 19, 2017 2:06 PM
To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
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
[email protected]<mailto:[email protected]>
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,
"[email protected]<mailto:[email protected]>
on behalf
of Oleksii Segeda"
<[email protected]<mailto:[email protected]>
on behalf of
[email protected]<mailto:[email protected]>> wrote:
>Hi everyone,
>
>Any thoughts on this?
>
>Oleksii.
>
>
>-----Original Message-----
>From: Oleksii Segeda
>Sent: Friday, June 16, 2017 6:16 PM
>To: [email protected]<mailto:[email protected]>
>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
>[email protected]<mailto:[email protected]>
>Manage your subscription at:
>http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general