Hi Peter,

Thanks for the reply. When I try that code, I get:

<error:format-string>XDMP-UNBPRFX: (err:XPST0081) Prefix db has no namespace 
binding</error:format-string>

Any ideas?

Thanks,

Ashley




[cid:image818465.PNG@81d95e71.44a37a73]


[cid:image5e5b83.PNG@18d0fd5d.4ab2e691]


Ashley Peacock


Developer II
Elevate Credit International Limited
P: 01284 717800 | Ext: 877 |  Elevate.co.uk<http://elevate.co.uk>
Amadeus House, Floral Street, Covent Garden, London WC2E 9DP




Privileged and Confidential. This e-mail, and any attachments thereto, is 
intended only for use by the addressee(s) named herein and may contain 
privileged and/or confidential information. If you have received this e-mail in 
error, please notify me immediately by a return e-mail and delete this e-mail. 
You are hereby notified that any dissemination, distribution or copying of this 
e-mail and/or any attachments thereto, is strictly prohibited.

Elevate Credit International Limited is registered in England & Wales with 
Company Number 05041905. Registered Office: 27-28 Eastcastle Street, London, 
W1W 8DH


From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Peter Kester
Sent: 02 February 2016 16:41
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Dynamically Create View Based On Indexes

Hi Ashley,

Try this:
xquery version "1.0-ml";
declare namespace db = "http://marklogic.com/xdmp/database";;
import module namespace admin = "http://marklogic.com/xdmp/admin";
 at "/MarkLogic/admin.xqy";
import module namespace view = "http://marklogic.com/xdmp/view";
      at "/MarkLogic/views.xqy";

let $seq := ()
let $indexes := 
admin:database-get-range-element-indexes(admin:get-configuration(), 
xdmp:database("BIR-rest-content"))
let $seq :=
for $i in $indexes
return (
 view:column($i/db:localname/text(), 
cts:element-reference(xs:QName($i/db:localname/text()))))

return $seq


HTH
Peter

From: 
<general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>>
 on behalf of Ashley Peacock 
<apeac...@elevate.co.uk<mailto:apeac...@elevate.co.uk>>
Reply-To: MarkLogic Developer Discussion 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Date: Tuesday 2 February 2016 16:55
To: "general@developer.marklogic.com<mailto:general@developer.marklogic.com>" 
<general@developer.marklogic.com<mailto:general@developer.marklogic.com>>
Subject: [MarkLogic Dev General] Dynamically Create View Based On Indexes

Hey,

I have the basic idea of how to achieve creating a view based on the current 
indexes on a field, I just can’t tie all the pieces together so hoping someone 
can help!

When calling admin:database-get-range-element-indexes() it returns a bunch of 
XML defining the indexes. I want to loop through each index, retrieve some 
values (the XML looks something like:

2016-02-02 14:14:28.322 Info: TaskServer: <range-element-index 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns="http://marklogic.com/xdmp/database";<http://marklogic.com/xdmp/database%22>>
2016-02-02 14:14:28.322 Info: TaskServer:   <scalar-type>int</scalar-type>
2016-02-02 14:14:28.322 Info: TaskServer:   <collation/>
2016-02-02 14:14:28.322 Info: TaskServer:   <namespace-uri/>
2016-02-02 14:14:28.322 Info: TaskServer:   <localname>localname</localname>
2016-02-02 14:14:28.322 Info: TaskServer:   
<range-value-positions>true</range-value-positions>
2016-02-02 14:14:28.322 Info: TaskServer:   
<invalid-values>ignore</invalid-values>
2016-02-02 14:14:28.322 Info: TaskServer: </range-element-index>

And store then in a sequence. I’ve tried the below to no luck, as my XQuery is 
not the strongest.

Let $seq := ()
For $i in admin:database-get-range-element-indexes(admin:get-configuration(), 
xdmp:database(‘myDatabase’))
Return fn:insert-before($seq, 0, view:column($i/range-element-index/localname, 
$i/range-element-index/localname)

But that doesn’t seem to work (there’s no error, it just doesn’t “do” anything).

Does anyone have any ideas?

Thanks,

Ashley



[cid:image001.jpg@01D15DD9.9F122D30]


[cid:image002.png@01D15DD9.9F122D30]


Ashley Peacock


Developer II
Elevate Credit International Limited
P: 01284 717800 | Ext: 877 |  Elevate.co.uk<http://elevate.co.uk>
Amadeus House, Floral Street, Covent Garden, London WC2E 9DP




Privileged and Confidential. This e-mail, and any attachments thereto, is 
intended only for use by the addressee(s) named herein and may contain 
privileged and/or confidential information. If you have received this e-mail in 
error, please notify me immediately by a return e-mail and delete this e-mail. 
You are hereby notified that any dissemination, distribution or copying of this 
e-mail and/or any attachments thereto, is strictly prohibited.

Elevate Credit International Limited is registered in England & Wales with 
Company Number 05041905. Registered Office: 27-28 Eastcastle Street, London, 
W1W 8DH




Click 
here<https://www.mailcontrol.com/sr/+S6suPqdY8XGX2PQPOmvUg0KooX!PhOyxcKI+jeB832L7gfUXjQAilsnEZCfbOQIwHpDQtigvFDaNxM9hG2QrA==>
 to report this email as spam.
_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to