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:
<[email protected]<mailto:[email protected]>>
on behalf of Ashley Peacock
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion
<[email protected]<mailto:[email protected]>>
Date: Tuesday 2 February 2016 16:55
To: "[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
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">
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:[email protected]]
[cid:[email protected]]
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
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general