Hi Asit Thank you for your reply.
While that search will certainly work, I neglected to mention that our document store is currently > 50 million documents (and increasing daily), and we need to perform the search in a timely fashion (preferably within 1 second), and therefore searching on XPath, especially using the // notation to search all elements of all documents, doesn't scale for that sort of environment. So we're really looking for a solution that use the cts:query logic so that we can leverage MarkLogic's indexes -- we've used this extremely successfully up to now for other queries, but haven't yet had to deal with a single user constraint being required to search the same attribute across multiple elements. Thanks. Iain Senior software engineer BBC FM Publishing Services Editorial Metadata On 28/08/13 14:56, [email protected] wrote: > Hi Iain, > > You can keep all documents in a collection and then use query like below : > > let $id := "abc123" > Return > cts:search(fn:collection("MyCollection")//*[@id[.=$id]],()) > > This query will give you that particular document which contain id="abc123" > > Similar you can use with combination > > let $id := "abc123" > let $alt-id :="zyx987" > Return > cts:search(fn:collection("MyCollection")//*[@id[.=$id]][@alt-id[.=$alt-id]],()) > > This query will give you that particular document which contain id="abc123" > and alt-id=" zyx987" > > Hope, it will help you. > > Regards, > Asit Nautiyal > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Iain Tatch > Sent: Wednesday, August 28, 2013 6:58 PM > To: General MarkLogic Developer Discussion > Subject: [MarkLogic Dev General] Constrained searches across multiple element > names > > Hello all > > We have the following (simplified) example documents: > > <cat id="abc123" alt-id="zyx987" xmlns="blah"> .. </cat> > > <dog id="aaa999" alt-id="bbb888" xmlns="blah"> .. </dog> > > <elephant id="xxxxxx" alt-id="yyyyyy" xmlns="blah"> .. </elephant> > > In other words, our documents are all in the same namespace, they all have > attributes @id and @alt-id, but the root node might be many different types > (I've specified 'cat', 'dog', 'elephant' here but in reality there are not > just 3, there are potentially dozens). > > We'd like to give our users the ability to search this data with queries such > as > > id:aaa999 > > or > > alt-id:zyx987 > > but I'm having trouble composing a valid set of Search constraint options to > achieve this. As far as I can tell, for both value constraints and word > constraints I'd need to specify an element name as well as the attribute > name, and obviously in this case there could be many different element names. > > > Any suggestions gratefully received! > > > TIA > Iain Tatch > Senior software engineer > BBC FM Publishing Services Editorial Metadata > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > 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 [email protected] http://developer.marklogic.com/mailman/listinfo/general
