Hi Erik, Thanks for your response. Could you please explain the process to move semantics out of attribute strings into element/attribute names? Also, if possible, could you mail the query to group the same currency values?
Thanks and Regards, Nachiketa From: [email protected] [mailto:[email protected]] On Behalf Of Erik Hennum Sent: Thursday, March 06, 2014 5:44 PM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] query for getting linked documents Hi, Nachiketa: Several XML modelling experts advocate against putting semantics in attribute value strings. In particular, MarkLogic can index usefully if you move the semantics out of attribute strings and into element or attribute names, as in: <currency>dollar</currency> You can then create a range index on currency and generate tuples with the co-occurrence of document uris and currency values, which will let you group document uris on the currency values. If you can't do that, one alternative is to read all of the documents into maps where the keys are the names and the values are uris. Reading all of the documents has severe scalability problems, which is why it is better to modify the model to make it possible to use indexes. Hoping that helps, Erik Hennum ________________________________ From: [email protected] [[email protected]] on behalf of Nachiketa Kulkarni [[email protected]] Sent: Thursday, March 06, 2014 3:31 AM To: [email protected] Subject: [MarkLogic Dev General] query for getting linked documents Hi, Please consider the below case: Document 1: <doc> <item name="fruit" value="apple"/> <item name="color" value="red"/> <item name="car" value="alto"/> <item name="currency" value="dollar"/> </doc> Document 2: <doc> <item name="vegetable" value="okra"/> <item name="fruit" value="apple"/> <item name="car" value="swift"/> <item name="currency" value="dollar"/> </doc> Document 3: <doc> <item name="fruit" value="banana"/> <item name="color" value="blue"/> <item name="car" value="verna"/> <item name="currency" value="rupee"/> </doc> Referring to the above example, two or more documents are said to be linked if the item element with @name = currency and their @value matches. Thus, in the above case, document 1 is linked to document 2 but not document 3. In order to get the URIs of all the linked document, I think of using the following approach: Since attribute range indexes on both @name and @value are available, all the matching @value for which @name = currency can be grouped together. Once all the groups are obtained, I will return the URI of the documents from each group. Using the URIs, I will add an element in each of the documents from a group which will serve as a link between them. However, I am not sure how I can form groups just by referring to range indexes. Please help me construct the XQUERY to get the desired result. Thanks and Regards, Nachiketa **************** CAUTION - Disclaimer ***************** This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS******** End of Disclaimer ********INFOSYS***
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
