Gnana,

The map is a hash map, so I assume the order of the elements is affected by how 
they get allocated to hash buckets. You could try this instead:

  let $x := (1,2,3,4,5, 9) ! xs:string(.)
  let $y := (2,3,6,7,9, 10, 11, 22, 101) ! xs:string(.)

  let $mx := map:map()

  let $add-all := for $i in $x return map:put($mx, xs:string($i), true())

  return $y[map:get($mx, .)]

You'll need to work a little harder if you really have numeric values because 
map keys have to be strings.

Geert is right that if you can have the database directly return lexicon 
values, that can be easier. Most lexicon functions have an option now to return 
data as a map.

Yours,
Damon


-----Original Message-----
From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of 
gnanaprakash.bodire...@cognizant.com
Sent: Thursday, June 27, 2013 4:47 AM
To: general@developer.marklogic.com
Subject: Re: [MarkLogic Dev General] Best approach for intersect/AND

Thanks Damon/Geert.

I tried with maps but saw some interesting results which I didn't expect.

When I perform map1 * map2, the results are ordered in different way than the 
original sequences.

Can you please let me know how map:put works? Will it keeps the keys in 
sequential manner? I think no.

For example:
When we try inserting 1,2,3 into a map after printing the keys are ordered as 
3,1,2

For just getting the intersect values map's are working as expected but looking 
at the ordering I want to understand maps in better way.

Regards,
Gnana(GP)

This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful.
_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to