I think you'd want a predicate rather than a SMO. This is an exhaustive search,
but it will probably be plenty fast because the map is already in memory anyway.
map:keys($m)[contains(., $substring)]
Or use a regex via fn:matches, etc. If you really need wildcards rather than
regex, you could build a text node around each key and use cts:contains. That's
necessary because cts:contains expects nodes - but that will be a little more
expensive too.
map:keys($m)[cts:contains(text { . }, $glob)]
But if the keyset is large enough that a scan isn't practical, there may be
other options. If you have a pretty good idea of what wildcard patterns you
need, you might be able to change the way you build keys. For example you could
insert wildcarded keys that map to the right keys.
If you know that the keys are based on a real element that has a range index,
you could use cts:element-value-match on that. But I think both of the previous
approaches are likely to be faster.
-- Mike
On 2 Aug 2013, at 06:40 , David Lee <[email protected]> wrote:
> Its not highly efficient but since maps are internally hash-maps there is no
> wildcard indexing on them.
> You have to manually iterate the keys.
> This or something like it (by memory) should work
>
> (map:keys( $map ) ! fn:contains(.,"*wildcard")) = fn:true()
>
>
>
>
>
> -----------------------------------------------------------------------------
> David Lee
> Lead Engineer
> MarkLogic Corporation
> [email protected]
> Phone: +1 812-482-5224
> Cell: +1 812-630-7622
> www.marklogic.com
>
>
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Steiner, David
> J. (LNG-DAY)
> Sent: Friday, August 02, 2013 9:34 AM
> To: MarkLogic Developer Discussion
> Subject: [MarkLogic Dev General] finding a set of keys in map
>
> Is there a way to find a group of map entries by “wildcarding” a key?
>
> Ideally, I’d like to say: map:contains($map, “*value-to-find”) and get back
> “true” if any of my keys contain “value-to-find”.
>
> Thanks,
> David
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general