Hi, Varun:

Your use case sounds very similar to the one given in the documentation:

    http://docs.marklogic.com/guide/search-dev/alerts#id_71547

In summary:

*  The serialized query in the rule should match the topic keywords.
*  The metadata in the rule should contains the list of users who have 
registered an interest in the topic.
*  The action should read the metadata and send the email.
*  The configuration should fire the alerts for new or changed documents.

In this approach, you won't need to update a list of new documents.

You will need to keep a separate document mapping topic keywords to users, but 
you planned to do that anyway.  The only difference is that you should put each 
topic in a separate document rather than in one document.

(In general, in working with MarkLogic, it's better to put each record in a 
separate document and aggregate as needed rather than put all records in a 
single document and extract as needed.)


Hoping that helps,


Erik Hennum

________________________________
From: [email protected] 
[[email protected]] on behalf of Varun Varunesh 
[[email protected]]
Sent: Wednesday, March 06, 2013 12:01 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] cts:reverse-query

Hello Charles,

Thanks for reply...

Charles if I will create a document for each keyword then again it becomes same 
problem as I facing with current solution.
Any other way to short out this problem from ML side.

Thanks,
Varun


On Thu, Mar 7, 2013 at 12:53 AM, Charles Greer 
<[email protected]<mailto:[email protected]>> wrote:
Hi Varun,

With reverse-query what you want to do is actually store the cts:query of 
interest within a document.  The query has to be serializable.  Then reverse 
query will return the document which contains a query that matches doc.xml.

So typically, you'd create a separate document for each keyword, which would 
look something like:

<query>
<cts:word-query xmlns:cts="http://marklogic.com/cts";>
<cts:text xml:lang="en">
[email protected]<mailto:[email protected]>
</cts:text>
</cts:word-query>
</query>

I made this by evaluating
<query>{cts:word-query("[email protected]"<mailto:[email protected]>)}</query>

Then, when I run something like
cts:search(/, cts:reverse-query(<doc>My name is 
[email protected]<mailto:[email protected]></doc>))

then the stored <query> doc above is returned.

Charles


On 03/06/2013 10:18 AM, Varun Varunesh wrote:

Hello All,
As I want to create an alert API. In which I am using two xml files say
user_id.xml and doc.xml .

The format of user_id.xml is like this
<data>
    <keyword name="MarkLogic">
         <mail>[email protected]<mailto:[email protected]></mail>
         <mail>[email protected]<mailto:[email protected]></mail>
         <mail>[email protected]<mailto:[email protected]></mail>
         <mail>[email protected]<mailto:[email protected]></mail>
    </keyword>
    <keyword name="google">
     .........
     .........
    </keyword>
</data>

Another file doc.xml contains all the recent document name inserted into my
ML database.

 Now, for each new document (those are present in doc.xml ) I want to do a
reverse query on the user_id.xml so that If the new document contains the
keyword(which is in user_id.xml)
 then mail can be send to all the email-id under that keyword.

Right now I have implemented this using simple search method which for each
document and for each keyword I am applying cts:contains and if it returns
true then I am sending mails
to all the emails under that keyword.
But this method will not work if we have large set of keywords with huge
no. of users.

So, suggest me how can I use cts:reverse-query to implements this.

Thanks.





_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
http://developer.marklogic.com/mailman/listinfo/general



--
Charles Greer
Senior Engineer
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Phone: +1 707 408 3277
www.marklogic.com<http://www.marklogic.com>


_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
http://developer.marklogic.com/mailman/listinfo/general


_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to