Skip to content

Instantly share code, notes, and snippets.

View eedeebee's full-sized avatar

Eric Bloch eedeebee

  • Hillsborough, CA
View GitHub Profile
@eedeebee
eedeebee / setup1.xqy
Last active January 2, 2016 03:49
Setup scripts for MarkLogic custom tokenization tutorial at http://developer.marklogic.com/learn/custom-tokenization
xquery version "1.0-ml";
(: Create the database and forest on current host :)
import module namespace admin="http://marklogic.com/xdmp/admin"
at "/MarkLogic/admin.xqy";
let $config := admin:get-configuration()
let $config :=
admin:database-create($config, "tweets",
xdmp:database("Security"), xdmp:database("Schemas"))
let $config := admin:forest-create($config, "tweetsF1", xdmp:host(), ())
<search:plan>
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:info-trace>xdmp:value("xdmp:plan(cts:search(fn:collection(),cts:query($query),$options,...")</qry:info-trace>
<qry:info-trace>Analyzing path for search: fn:collection()</qry:info-trace>
<qry:info-trace>Step 1 is searchable: fn:collection()</qry:info-trace>
<qry:info-trace>Path is fully searchable.</qry:info-trace>
<qry:info-trace>Gathering constraints.</qry:info-trace>
<qry:field-word-trace text="@NASA" field-name="tweet">
<qry:key>12422997346279939379</qry:key>
</qry:field-word-trace>
@eedeebee
eedeebee / query-plan-results.xml
Created December 18, 2013 01:18
Search query plan
<search:plan>
<qry:query-plan xmlns:qry="http://marklogic.com/cts/query">
<qry:info-trace>xdmp:value("xdmp:plan(cts:search(fn:collection(),cts:query($query),$options,...")</qry:info-trace>
<qry:info-trace>Analyzing path for search: fn:collection()</qry:info-trace>
<qry:info-trace>Step 1 is searchable: fn:collection()</qry:info-trace>
<qry:info-trace>Path is fully searchable.</qry:info-trace>
<qry:info-trace>Gathering constraints.</qry:info-trace>
<qry:word-trace text="NASA">
<qry:key>3178996703552976097</qry:key>
</qry:word-trace>
@eedeebee
eedeebee / query-plan-search-options.xml
Last active December 31, 2015 16:49
Query plan search options
<options xmlns="http://marklogic.com/appservices/search">
<search-option>unfiltered</search-option>
<quality-weight>0</quality-weight>
<return-plan>true</return-plan>
<debug>true</debug>
</options>
@eedeebee
eedeebee / default-search-results.xml
Last active December 31, 2015 16:48
Tweet search results
<tweet>@NASA thanks for inviting me to the social! I'm learning so much!</tweet>
<tweet>Rumour has it NASA is announcing MSL finding organic carbon at press conference Tuesday.</tweet>
<tweet>Streambed on Mars! #NASA #MSL</tweet>
@eedeebee
eedeebee / tweet-1.xml
Last active December 31, 2015 16:39
Sample tweets
<doc>
<user>spacecadet47</user>
<mobile>(650)701-1212</mobile>
<impact-score>45.21</impact-score>
<dt>2013-11-01T12:00:22</dt>
<location lat="34.156111" long="-118.1319443">Pasadena</location>
<tweet>@NASA thanks for inviting me to the social! I'm learning so much!</tweet>
</doc>
@eedeebee
eedeebee / 0_reuse_code.js
Created December 18, 2013 00:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@eedeebee
eedeebee / bbq.xqy
Created December 11, 2013 21:51
MarkLogic XQuery Search API - 5 minute guide - data loader
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() )
xquery version "1.0-ml";
module namespace addr="http://example.org/address";
declare namespace rxq="http://exquery.org/ns/restxq";
declare
%rxq:GET
%rxq:path('/address/id/(.*)')
%rxq:produces('text/html')
function addr:get-address($id){
declare variable $RESOURCE-URL := "@ml.resource-url";
(: Becomes... :)
declare variable $RESOURCE-URL := "http://some.resource.com";