Created
December 11, 2013 21:51
-
-
Save eedeebee/7919139 to your computer and use it in GitHub Desktop.
MarkLogic XQuery Search API - 5 minute guide - data loader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "1.0-ml"; | |
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy"; | |
( | |
let $config := admin:get-configuration() | |
let $dbid := xdmp:database("barbecue") | |
let $rangespec := | |
admin:database-range-element-attribute-index("dateTime", | |
"http://example.com", "entry", "", "date", | |
"", fn:false() ) | |
let $config := admin:database-add-range-element-attribute-index($config, $dbid, $rangespec) | |
let $rangespec := | |
admin:database-range-element-index("int", | |
"http://example.com", "scoville", "", fn:false() ) | |
let $config := admin:database-add-range-element-index($config, $dbid, | |
$rangespec) | |
let $rangespec := | |
admin:database-range-element-index("decimal", | |
"http://example.com", "rating", "", fn:false() ) | |
let $config := admin:database-add-range-element-index($config, $dbid, | |
$rangespec) | |
let $fieldspec := admin:database-field("bbqtext", fn:true() ) | |
let $config := admin:database-add-field($config, $dbid, $fieldspec) | |
let $fieldspec := admin:database-included-element("http://example.com", | |
"title", 1.0, "", "", "") | |
let $config := admin:database-set-collection-lexicon($config, $dbid, fn:true()) | |
let $config := admin:database-add-field-included-element($config, $dbid, | |
"bbqtext", $fieldspec) | |
return admin:save-configuration($config) | |
, | |
xdmp:document-insert("http://bbqdocs/entry1", | |
<entry xmlns="http://example.com" date="2007-10-31T14:17:44.425-07:00"> | |
<title>Sally's Southern BBQ</title> | |
<abstract>A classic southern recipe</abstract> | |
<flavor-descriptor>cayanne</flavor-descriptor> | |
<flavor-descriptor>molasses</flavor-descriptor> | |
<flavor-descriptor>smoky</flavor-descriptor> | |
<scoville>800</scoville> | |
<rating>3.0</rating> | |
</entry>, | |
(), | |
"http://bbq.com/contributor/AuntSally" | |
) | |
, | |
xdmp:document-insert("http://bbqdocs/entry2", | |
<entry xmlns="http://example.com" date="2008-07-01T11:44:32.345-07:00"> | |
<title>Red, Hot, and Blue</title> | |
<abstract>Texas-style sauce with extra heat</abstract> | |
<flavor-descriptor>habeñero</flavor-descriptor> | |
<flavor-descriptor>black pepper</flavor-descriptor> | |
<flavor-descriptor>smoky</flavor-descriptor> | |
<scoville>72000</scoville> | |
<rating>4.0</rating> | |
</entry>, | |
(), | |
"http://bbq.com/contributor/BigTex" | |
) | |
, | |
xdmp:document-insert("http://bbqdocs/entry3", | |
<entry xmlns="http://example.com" date="2009-03-03T13:18:58.225-07:00"> | |
<title>Louisiana Bayou Mild</title> | |
<abstract>Straight from New Orleans, mild and sweet</abstract> | |
<flavor-descriptor>sweet</flavor-descriptor> | |
<flavor-descriptor>vinegar</flavor-descriptor> | |
<scoville>750</scoville> | |
<rating>5.0</rating> | |
</entry>, | |
(), | |
"http://bbq.com/contributor/Dubois" | |
) | |
, | |
xdmp:document-insert("http://bbqdocs/entry4", | |
<entry xmlns="http://example.com" date="2009-04-07T14:44:27.550-07:00"> | |
<title>Four little pigs</title> | |
<abstract>Southern Texas-style sauce with extreme heat</abstract> | |
<flavor-descriptor>habeñero</flavor-descriptor> | |
<flavor-descriptor>black pepper</flavor-descriptor> | |
<flavor-descriptor>smoky</flavor-descriptor> | |
<flavor-descriptor>brown sugar</flavor-descriptor> | |
<scoville>88000</scoville> | |
<rating>5.0</rating> | |
</entry>, | |
(), | |
"http://bbq.com/contributor/BigTex" | |
) | |
, | |
xdmp:document-insert("http://bbqdocs/entry5", | |
<entry xmlns="http://example.com" date="2009-07-04T13:32:52-07:00"> | |
<title>Kansas City Apple Cinnamon</title> | |
<abstract>Specialty recipe made with real fruit and spices</abstract> | |
<flavor-descriptor>apple</flavor-descriptor> | |
<flavor-descriptor>cinnamon</flavor-descriptor> | |
<flavor-descriptor>brown sugar</flavor-descriptor> | |
<scoville>1000</scoville> | |
<rating>2.0</rating> | |
</entry>, | |
(), | |
"http://bbq.com/contributor/Dorothy" | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment