My understanding is that the eval host simply doesn't know until it tries to
use the id. I think the most efficient way would be to try the cheapest
possible database check in your query builder:
xdmp:exists(cts:search(doc(), cts:registered-query($query-id, "unfiltered")))
You could wrap that in a user function if it makes you feel better, but it will
still require a database lookup. Naturally you would want the usual try-catch
too.
You might even supply a forest argument to cts:search, so that you only check a
single (local?) forest. But that might cause problems too. I seem to recall
that registered queries can persist differently in different forests within the
same databse.
Have you profiled the work of rebuilding the query? How long does it take?
-- Mike
On 28 Feb 2012, at 10:03 , Ron Hitchens wrote:
>
> Is there a supported way of discovering if a registered
> query ID is still registered?
>
> In the docs, it describes that a cts:search will throw
> an exception if an instance of cts:registered-query refers
> to a no-longer-valid registered query ID, but this is too
> late to be helpful to me.
>
> I also know that I can re-register a query on every use
> and it will hash to the same ID, but that is also not helpful
> in this use case.
>
> I need to build complex access-control queries with
> potentially thousands of terms. These terms are derived
> from parsing JSON descriptions that are then used to fetch
> stored query fragments which are combined and then registered
> together.
>
> The same, arbitrarily complex JSON strings are re-used often.
> What I want to do it use a hash of the JSON as a key to identify
> which registered query to apply. It's the effort of building
> the query from the JSON that I want to avoid.
>
> I can make a run-time map of JSON hash values to registered
> query IDs, that's easy. But I can't see a reliable way to
> determine if a given registration key is still valid.
>
> Because the queries are built up separately from where
> the search ultimately happens, it's not very practical to
> catch an exception at cts:search time and rewind to build
> the query.
>
> Does anyone have a solution for enquiring if a registered
> query ID is still safe to use?
>
> Thanks.
>
> ---
> Ron Hitchens {mailto:[email protected]} Ronsoft Technologies
> +44 7879 358 212 (voice) http://www.ronsoft.com
> +1 707 924 3878 (fax) Bit Twiddling At Its Finest
> "No amount of belief establishes any fact." -Unknown
>
>
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general