Hi Sachin,

You can try *cts:element-value-co-occurrences*.

Regards,
Arvind Kr.

On Mon, Aug 17, 2015 at 12:26 PM, Sachin Sharma <[email protected]>
wrote:

> Hi,
>
>          I wish to know concept of joins(natural join) in MarkLogic. I am
> fetching records from 3 files. The files are having following structure
>
> *First  File.xml*
>
>
>
> *<Result>*
>
> *<Details><Name>Ashish</Name><Age>25</Age></Details>*
>
> *<Details><Name>Sachin</Name><Age>23</Age></Details>*
>
> *</Result>*
>
>
>
> *Second File.xml*
>
>
>
> *<Result>*
>
> *<Details><Name>Ashish</Name><Age>25</Age></Details>*
>
> *<Details><Name>Sachin</Name><Age>23</Age></Details>*
>
> *<Details><Name>Mohan</Name><Age>26</Age></Details>*
>
> *<Details><Name>Parth</Name><Age>27</Age></Details>*
>
> *</Result>*
>
>
>
> *Third File.xml*
>
>
>
> *<Result>*
>
> *<Details><Name>Ashish</Name><Age>25</Age></Details>*
>
> *<Details><Name>Sachin</Name><Age>23</Age></Details>*
>
> *<Details><Name>Neha</Name><Age>14</Age></Details>*
>
> *</Result>*
>
>
>
>
>
>
>
> I want  to fetch common records from all three files. Currently I am
> fetching values of  *<s>* using *cts:element-values,* storing it in map
> and  comparing 2 maps using following code:
>
>
>
> *declare* *function* local:intersection($a *as* xs:string*,$b *as*
>  xs:string*) *as* xs:string*
>
> {
>
> *let* $desig-map := map:map()
>
> *let* $temp-map := map:map()
>
> *let* $sachin:=map:map()
>
> *let* $m1:=*for* $i *in* $a
>
>          *return* map:put($desig-map, $i, "a")
>
>
>
> *let* $m2:=*for* $j *in* $b
>
>          *return* map:put($temp-map, $j, "a")
>
>
>
> *let* $q:= ($desig-map)-($temp-map)
>
> *let* $r:=($temp-map)-($desig-map)
>
> *let* $total:=($temp-map)+ ($desig-map)
>
> *let* $final:=($total - ($q + $r))
>
> *return* map:keys($final)
>
> };
>
>
>
> The current implementation of fetching common records is time consuming as
> it keeps on comparing all 3 values. I want to know the fastest and best
> approach to fetch common records from multiples files.
>
>
>
> Regards
>
> Sachin Sharma
>
>
>
>
>
>
>
>
>
> _______________________________________________
> General mailing list
> [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

Reply via email to