True, but server-fields may be overkill for this problem.

Registered queries have used consistent hashing since some 4.x revision. So the 
simplest implementation is to register the query every time. It will always get 
the same id, and it will only do the work if the query was not previously 
registered.

    cts:register(cts:word-query('fubar'))
    =>
    2665245610683947004

    count(
      distinct-values(
        for $i in 1 to 100
        return cts:register(cts:word-query('fubar'))))
    =>
    1
    PT0.006407S

Re-registering an existing query takes a negligible amount of time. On my 
laptop, I can re-register the same query 50,000 times in less than one second: 
about 60-µs per re-registration. The query evaluation will swamp that cost by 
2-4 orders of magnitude.

    distinct-values(
    for $i in 1 to 50000
    return cts:register(cts:word-query('fubar')))
    , xdmp:elapsed-time()
    =>
    1
    PT0.961158S

-- Mike

On 8 Feb 2012, at 11:28 , Keith Breinholt wrote:

> MarkLogic server fields are specific to the host.
> 
> 
> 
> If you have a load balancer in front of the MarkLogic servers one solution is 
> to set the session sticky bit so that a client session always goes to the 
> same MarkLogic host.
> 
> 
> 
> On Wed, Feb 8, 2012 at 12:02 PM, Abhishek53 S <[email protected]> wrote:
> 
> Hi Folks, 
> 
> I have 4 nodes [All mixed DNode+ENode] across cluster. I am using server 
> fields to store a map that consists of user-id and registered query-id 
> mapping. When I am trying to get server field value by pointing one node of 
> the cluster it is returning different registered query id than the others. Is 
> it possible that the server fields values are not in sync across nodes in the 
> cluster - As per my understanding for same application server the value 
> remain same across nodes. 
> 
> Is it possible to see the server field value from CQ. 
> 
> Abhishek Srivastav
> Systems Engineer
> Tata Consultancy Services
> Cell:- +91-9883389968
> Mailto: [email protected]
> Website: http://www.tcs.com
> ____________________________________________
> Experience certainty.        IT Services
>                        Business Solutions
>                        Outsourcing
> ____________________________________________
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain 
> confidential or privileged information. If you are 
> not the intended recipient, any dissemination, use, 
> review, distribution, printing or copying of the 
> information contained in this e-mail message 
> and/or attachments to it are strictly prohibited. If 
> you have received this communication in error, 
> please notify us by reply e-mail or telephone and 
> immediately and permanently delete the message 
> and any attachments. Thank you
> 
> 
> 
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> 
> 
> 
> 
> -- 
> Keith
> "Do what you can, with what you have, where you are." - Theodore Roosevelt
> _______________________________________________
> General mailing list
> [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