Code samples for MarkLogic REST API
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
curl -X GET \ | |
--anyauth --user rest-writer:x \ | |
'http://localhost:8011/v1/search?q=chicken&format=json' |
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
curl -v -X PUT \ | |
--digest --user rest-writer:x \ | |
-d'{"recipe":"Apple pie", "fromScratch":true, "ingredients":"The Universe"}' \ | |
-H "Content-type: application/json" \ | |
'http://localhost:8011/v1/documents?uri=/example/recipe.json' |
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
curl -v -X PUT \ | |
--digest --user rest-writer:x \ | |
-d'{"recipe":"Apple pie", "fromScratch":true, "ingredients":"The Universe"}' \ | |
'http://localhost:8011/v1/documents?uri=/example/recipe.json&format=json' |
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
curl -v -X PUT \ | |
--digest --user rest-writer:x \ | |
-d'<person><first>Carl</first><last>Sagan</last></person>' \ | |
'http://localhost:8011/v1/documents?uri=/example/person.xml' |
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
curl -v -X PUT \ | |
--digest --user rest-writer:x \ | |
-d'<person><first>Carl</first><last>Sagan</last></person>' \ | |
-H "Content-type: application/xml" \ | |
'http://localhost:8011/v1/documents?uri=/example/person.xml' |
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
curl -v -X PUT \ | |
--digest --user rest-writer:x \ | |
-d'This is a text file.' \ | |
-H "Content-type: text/plain" \ | |
'http://localhost:8011/v1/documents?uri=/foo.txt&collection=examples&collection=mine' |
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
curl http://developer.marklogic.com/media/learn/rest/mlfavicon.png >mlfavicon.png | |
curl -v -X PUT \ | |
--digest --user rest-writer:x \ | |
--data-binary '@mlfavicon.png' \ | |
-H "Content-type: image/png" \ | |
'http://localhost:8011/v1/documents?uri=/example/mlfavicon.png&extract=properties' |
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
curl -v -X DELETE \ | |
--digest --user rest-writer:x \ | |
'http://localhost:8011/v1/documents?uri=/foo.txt' |
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
curl -v -X POST \ | |
--digest --user rest-writer:x \ | |
-d'{"query":{"properties-query":{"term-query":{"text":"fish"}}}}' \ | |
-H "Content-type: application/json" \ | |
'http://localhost:8011/v1/search?format=json' |
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
curl -v -X POST \ | |
--digest --user rest-writer:x \ | |
-d'<query xmlns="http://marklogic.com/appservices/search"><properties-query><term-query><text>fish</text></term-query></properties-query></query>' \ | |
-H "Content-type: application/xml" \ | |
'http://localhost:8011/v1/search' |
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
"total":95,"start":1,"page-length":10 |
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
"results": [ | |
{ | |
"index": 1, | |
"uri": "/guide/search-dev.xml", | |
"path": "fn:doc(\"/guide/search-dev.xml\")", | |
"score": 92032, | |
"confidence": 0.672178, | |
"fitness": 0.877356, | |
"matches": [ | |
{ | |
"path": "fn:doc(\"/guide/search-dev.xml\")/*:guide/*:para[5]", | |
"match-text": [ | |
"Lexicon and ", | |
{ | |
"highlight": "Range Index" | |
}, | |
"-Based APIs..." | |
}, | |
{ | |
"path": "fn:doc(\"/guide/search-dev.xml\")/*:guide/*:para[20]", | |
"match-text": [ | |
"no matter what the database size. As part of loading a document, full-text ", | |
{ | |
"highlight": "indexes" | |
}, | |
"are created making arbitrary searches fast. Searches automatically use the" | |
} | |
] | |
} | |
] |
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
"results": [ | |
{ | |
"index": 1, | |
"uri": "/guide/search-dev.xml", | |
"path": "fn:doc(\"/guide/search-dev.xml\")", | |
"score": 92032, | |
"confidence": 0.672178, | |
"fitness": 0.877356, | |
"matches": [ | |
{ | |
"path": "fn:doc(\"/guide/search-dev.xml\")/*:guide/*:para[5]", | |
"match-text": [ | |
"Lexicon and ", | |
{ | |
"highlight": "Range Index" | |
}, | |
"-Based APIs..." | |
}, | |
{ | |
"path": "fn:doc(\"/guide/search-dev.xml\")/*:guide/*:para[20]", | |
"match-text": [ | |
"no matter what the database size. As part of loading a document, full-text ", | |
{ | |
"highlight": "indexes" | |
}, | |
"are created making arbitrary searches fast. Searches automatically use the" | |
} | |
] | |
} | |
] |
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
"total":95,"start":1,"page-length":10 |
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
"results": [ | |
{ | |
"index": 1, | |
"uri": "/guide/search-dev.xml", | |
"path": "fn:doc(\"/guide/search-dev.xml\")", | |
"score": 92032, | |
"confidence": 0.672178, | |
"fitness": 0.877356, | |
"matches": [ | |
{ | |
"path": "fn:doc(\"/guide/search-dev.xml\")/*:guide/*:para[5]", | |
"match-text": [ | |
"Lexicon and ", | |
{ | |
"highlight": "Range Index" | |
}, | |
"-Based APIs..." | |
}, | |
{ | |
"path": "fn:doc(\"/guide/search-dev.xml\")/*:guide/*:para[20]", | |
"match-text": [ | |
"no matter what the database size. As part of loading a document, full-text ", | |
{ | |
"highlight": "indexes" | |
}, | |
"are created making arbitrary searches fast. Searches automatically use the" | |
} | |
] | |
} | |
] |
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
[{"name":"default","uri":"/v1/config/query/default"}] |
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
<!--...--> | |
<result index="1" | |
uri="/guide/search-dev.xml" | |
path="fn:doc("/guide/search-dev.xml")" | |
score="92032" | |
confidence="0.672178" | |
fitness="0.877356"> | |
<snippet> | |
<match path="fn:doc("/guide/search-dev.xml")/*:guide/*:para[5]" | |
>Lexicon and <highlight>Range Index</highlight>-Based APIs...</match> | |
<match path="fn:doc("/guide/search-dev.xml")/*:guide/*:para[20]" | |
>no matter what the database size. As part of loading a document, | |
full-text <highlight>indexes</highlight> are created making | |
arbitrary searches fast. Searches automatically use the</match> | |
</snippet> | |
</result> | |
<!--...--> |
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
curl -v -X PUT \ | |
--digest --user rest-admin:x \ | |
-d'{options:{constraint:[{name:"tag",collection:{prefix:""}}]}}' \ | |
-H "Content-type: application/json" \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<!--...--> | |
<result index="1" | |
uri="/guide/search-dev.xml" | |
path="fn:doc("/guide/search-dev.xml")" | |
score="92032" | |
confidence="0.672178" | |
fitness="0.877356"> | |
<snippet> | |
<match path="fn:doc("/guide/search-dev.xml")/*:guide/*:para[5]" | |
>Lexicon and <highlight>Range Index</highlight>-Based APIs...</match> | |
<match path="fn:doc("/guide/search-dev.xml")/*:guide/*:para[20]" | |
>no matter what the database size. As part of loading a document, | |
full-text <highlight>indexes</highlight> are created making | |
arbitrary searches fast. Searches automatically use the</match> | |
</snippet> | |
</result> | |
<!--...--> |
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
[{"name":"default","uri":"/v1/config/query/default"}] |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="tag"> | |
<collection prefix=""/> | |
</constraint> | |
</options> |
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
<rapi:query-options xmlns:rapi="http://marklogic.com/rest-api"> | |
<rapi:options> | |
<rapi:name>default</rapi:name> | |
<rapi:uri>/v1/config/query/default</rapi:uri> | |
</rapi:options> | |
</rapi:query-options> |
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
[{"name":"default","uri":"/v1/config/query/default"}] |
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
curl -v -X PUT \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"tag","collection":{"prefix":""}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"collection": { | |
"prefix": "" | |
}, | |
"name": "tag" | |
} | |
] | |
} | |
} |
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
curl -v -X PUT \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"tag","collection":{"prefix":""}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"collection": { | |
"prefix": "" | |
}, | |
"name": "tag" | |
} | |
] | |
} | |
} |
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
// create a search definition using the "tutorial" options | |
StringQueryDefinition query = queryMgr.newStringDefinition("tutorial"); |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="tag"> | |
<collection prefix=""/> | |
</constraint> | |
</options> |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"company","value":{"json-key":"affiliation"}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="tag"> | |
<collection prefix=""/> | |
</constraint> | |
</options> |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"name": "company", | |
"value": { | |
"json-key": "affiliation" | |
} | |
} | |
] | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"company","value":{"json-property":"affiliation"}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"name": "company", | |
"value": { | |
"json-property": "affiliation" | |
} | |
} | |
] | |
} | |
} |
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
// find plays featuring the King of France | |
query.setCriteria("person:\"KING OF FRANCE\""); |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="company"> | |
<value> | |
<json-key>affiliation</json-key> | |
</value> | |
</constraint> | |
</options> |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"person","value":{"element":{"name":"SPEAKER","ns":""}}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="company"> | |
<value> | |
<json-property>affiliation</json-property> | |
</value> | |
</constraint> | |
</options> |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"name": "person", | |
"value": { | |
"element": { | |
"name": "SPEAKER", | |
"ns": "" | |
} | |
} | |
} | |
] | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"person","value":{"element":{"name":"PERSONA","ns":""}}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"name": "person", | |
"value": { | |
"element": { | |
"name": "PERSONA", | |
"ns": "" | |
} | |
} | |
} | |
] | |
} | |
} |
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
tutorialOpts.addConstraint( | |
qob.constraint("stagedir", | |
qob.word( | |
qob.elementTermIndex(new QName("STAGEDIR"))))); |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="person"> | |
<value> | |
<element ns="" name="PERSONA"/> | |
</value> | |
</constraint> | |
</options> |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"bio","word":{"json-key":"bio"}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="person"> | |
<value> | |
<element ns="" name="PERSONA"/> | |
</value> | |
</constraint> | |
</options> |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"name": "bio", | |
"word": { | |
"json-key": "bio" | |
} | |
} | |
] | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"bio","word":{"json-property":"bio"}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"name": "bio", | |
"word": { | |
"json-property": "bio" | |
} | |
} | |
] | |
} | |
} |
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
// search for mentions of swords in the script itself | |
query.setCriteria("spoken:sword"); |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="bio"> | |
<word> | |
<json-key>bio</json-key> | |
</word> | |
</constraint> | |
</options> |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"stagedir","word":{"element":{"name":"STAGEDIR","ns":""}}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="bio"> | |
<word> | |
<json-property>bio</json-property> | |
</word> | |
</constraint> | |
</options> |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"name": "stagedir", | |
"word": { | |
"element": { | |
"name": "STAGEDIR", | |
"ns": "" | |
} | |
} | |
} | |
] | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"stagedir","word":{"element":{"name":"STAGEDIR","ns":""}}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"name": "stagedir", | |
"word": { | |
"element": { | |
"name": "STAGEDIR", | |
"ns": "" | |
} | |
} | |
} | |
] | |
} | |
} |
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
// create a query builder using the "tutorial" options | |
StructuredQueryBuilder qb = new StructuredQueryBuilder("tutorial"); |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="stagedir"> | |
<word> | |
<element ns="" name="STAGEDIR"/> | |
</word> | |
</constraint> | |
</options> |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"spoken","element-query":{"name":"SPEECH","ns":""}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="stagedir"> | |
<word> | |
<element ns="" name="STAGEDIR"/> | |
</word> | |
</constraint> | |
</options> |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"element-query": { | |
"name": "SPEECH", | |
"ns": "" | |
}, | |
"name": "spoken" | |
} | |
] | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"spoken","element-query":{"name":"SPEECH","ns":""}}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"element-query": { | |
"name": "SPEECH", | |
"ns": "" | |
}, | |
"name": "spoken" | |
} | |
] | |
} | |
} |
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
// create a builder for constructing query options | |
QueryOptionsBuilder qob = new QueryOptionsBuilder(); | |
// expose the collection lexicon as "tag" values | |
QueryOptionsHandle options = new QueryOptionsHandle().withValues( | |
qob.values("tag", | |
qob.collection(""))); |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="spoken"> | |
<element-query ns="" name="SPEECH"/> | |
</constraint> | |
</options> |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"image","properties":null}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="spoken"> | |
<element-query ns="" name="SPEECH"/> | |
</constraint> | |
</options> |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"name": "image", | |
"properties": null | |
} | |
] | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"image","properties":null}]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"name": "image", | |
"properties": null | |
} | |
] | |
} | |
} |
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
// retrieve the values | |
ValuesHandle valuesHandle = queryMgr.values(valuesDef, new ValuesHandle()); |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="image"> | |
<properties/> | |
</constraint> | |
</options> |
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
{"query": | |
{"or-query": | |
{"queries":[ | |
{"and-query": | |
{"queries":[ | |
{"word-constraint-query": | |
{"constraint-name":"bio", | |
"text":["product"]}}, | |
{"value-constraint-query": | |
{"constraint-name":"company", | |
"text":["MarkLogic"]}}]}}, | |
{"and-query": | |
{"queries":[ | |
{"element-constraint-query": | |
{"constraint-name":"spoken", | |
"and-query": | |
{"queries":[ | |
{"term-query": | |
{"text":["fie"]}}]}}}, | |
{"word-constraint-query": | |
{"constraint-name":"stagedir", | |
"text":["fall"]}}, | |
{"value-constraint-query": | |
{"constraint-name":"person", | |
"text":["GRUMIO"]}}]}}, | |
{"and-query": | |
{"queries":[ | |
{"properties-query": | |
{"term-query": | |
{"text":["fish"]}}}, | |
{"infinite":true, | |
"directory-query": | |
{"uri":["/images/2012/02/27/"]}}]}}, | |
{"and-query": | |
{"queries":[ | |
{"collection-query": | |
{"uri":["mlw2012"]}}, | |
{"term-query": | |
{"text":["fun"]}}]}}]}}} |
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
// print out the values and their frequencies | |
for (CountedDistinctValue value : valuesHandle.getValues()) { | |
System.out.println( | |
value.get("xs:string",String.class) + ": " + value.getCount()); | |
} |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<constraint name="image"> | |
<properties/> | |
</constraint> | |
</options> |
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
{"query": | |
{"or-query": | |
{"queries":[ | |
{"and-query": | |
{"queries":[ | |
{"word-constraint-query": | |
{"constraint-name":"bio", | |
"text":["product"]}}, | |
{"value-constraint-query": | |
{"constraint-name":"company", | |
"text":["MarkLogic"]}}]}}, | |
{"and-query": | |
{"queries":[ | |
{"element-constraint-query": | |
{"constraint-name":"spoken", | |
"and-query": | |
{"queries":[ | |
{"term-query": | |
{"text":["fie"]}}]}}}, | |
{"word-constraint-query": | |
{"constraint-name":"stagedir", | |
"text":["fall"]}}, | |
{"value-constraint-query": | |
{"constraint-name":"person", | |
"text":["GRUMIO"]}}]}}, | |
{"and-query": | |
{"queries":[ | |
{"properties-query": | |
{"term-query": | |
{"text":["fish"]}}}, | |
{"infinite":true, | |
"directory-query": | |
{"uri":["/images/2012/02/27/"]}}]}}, | |
{"and-query": | |
{"queries":[ | |
{"collection-query": | |
{"uri":["mlw2012"]}}, | |
{"term-query": | |
{"text":["fun"]}}]}}]}}} |
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
// expose the URI lexicon as "uri" values | |
QueryOptionsHandle options = new QueryOptionsHandle().withValues( | |
qob.values("uri", | |
qob.uri())); |
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
<query xmlns="http://marklogic.com/appservices/search"> | |
<or-query> | |
<and-query> | |
<word-constraint-query> | |
<constraint-name>bio</constraint-name> | |
<text>product</text> | |
</word-constraint-query> | |
<value-constraint-query> | |
<constraint-name>company</constraint-name> | |
<text>MarkLogic</text> | |
</value-constraint-query> | |
</and-query> | |
<and-query> | |
<element-constraint-query> | |
<constraint-name>spoken</constraint-name> | |
<term-query> | |
<text>fie</text> | |
</term-query> | |
</element-constraint-query> | |
<word-constraint-query> | |
<constraint-name>stagedir</constraint-name> | |
<text>fall</text> | |
</word-constraint-query> | |
<value-constraint-query> | |
<constraint-name>person</constraint-name> | |
<text>GRUMIO</text> | |
</value-constraint-query> | |
</and-query> | |
<and-query> | |
<properties-query> | |
<term-query> | |
<text>fish</text> | |
</term-query> | |
</properties-query> | |
<directory-query> | |
<uri>/images/2012/02/27/</uri> | |
<infinite>true</infinite> | |
</directory-query> | |
</and-query> | |
<and-query> | |
<collection-query> | |
<uri>mlw2012</uri> | |
</collection-query> | |
<term-query> | |
<text>fun</text> | |
</term-query> | |
</and-query> | |
</or-query> | |
</query> |
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
curl -v -X POST \ | |
--digest --user rest-writer:x \ | |
-H "Content-type: application/json" \ -d'{"query":{"or-query":{"queries":[{"and-query":{"queries":[ {"word-constraint-query":{"constraint-name":"bio","text":["product"]}}, {"value-constraint-query":{"constraint-name":"company","text":["MarkLogic"]}} ]}}, {"and-query":{"queries":[ {"element-constraint-query":{"constraint-name":"spoken","and-query": {"queries":[{"term-query":{"text":["fie"]}}]} }}, {"word-constraint-query":{"constraint-name":"stagedir","text":["fall"]}}, {"value-constraint-query":{"constraint-name":"person","text":["GRUMIO"]}} ]}}, {"and-query":{"queries":[ {"properties-query":{"term-query":{"text":["fish"]}}}, {"directory-query":{"uri":["/images/2012/02/27/"]},"infinite":true} ]}}, {"and-query":{"queries":[ {"collection-query":{"uri":["mlw2012"]}}, {"term-query":{"text":["fun"]}} ]}}]}}}' \ | |
'http://localhost:8011/v1/search?options=tutorial' |
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
<query xmlns="http://marklogic.com/appservices/search"> | |
<or-query> | |
<and-query> | |
<word-constraint-query> | |
<constraint-name>bio</constraint-name> | |
<text>product</text> | |
</word-constraint-query> | |
<value-constraint-query> | |
<constraint-name>company</constraint-name> | |
<text>MarkLogic</text> | |
</value-constraint-query> | |
</and-query> | |
<and-query> | |
<element-constraint-query> | |
<constraint-name>spoken</constraint-name> | |
<term-query> | |
<text>fie</text> | |
</term-query> | |
</element-constraint-query> | |
<word-constraint-query> | |
<constraint-name>stagedir</constraint-name> | |
<text>fall</text> | |
</word-constraint-query> | |
<value-constraint-query> | |
<constraint-name>person</constraint-name> | |
<text>GRUMIO</text> | |
</value-constraint-query> | |
</and-query> | |
<and-query> | |
<properties-query> | |
<term-query> | |
<text>fish</text> | |
</term-query> | |
</properties-query> | |
<directory-query> | |
<uri>/images/2012/02/27/</uri> | |
<infinite>true</infinite> | |
</directory-query> | |
</and-query> | |
<and-query> | |
<collection-query> | |
<uri>mlw2012</uri> | |
</collection-query> | |
<term-query> | |
<text>fun</text> | |
</term-query> | |
</and-query> | |
</or-query> | |
</query> |
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
curl -v -X POST \ | |
--digest --user rest-writer:x \ | |
-H "Content-type: application/json" \ -d'{"query":{"or-query":{"queries":[{"and-query":{"queries":[ {"word-constraint-query":{"constraint-name":"bio","text":["product"]}}, {"value-constraint-query":{"constraint-name":"company","text":["MarkLogic"]}} ]}}, {"and-query":{"queries":[ {"element-constraint-query":{"constraint-name":"spoken","and-query": {"queries":[{"term-query":{"text":["fie"]}}]} }}, {"word-constraint-query":{"constraint-name":"stagedir","text":["fall"]}}, {"value-constraint-query":{"constraint-name":"person","text":["GRUMIO"]}} ]}}, {"and-query":{"queries":[ {"properties-query":{"term-query":{"text":["fish"]}}}, {"directory-query":{"uri":["/images/2012/02/27/"]},"infinite":true} ]}}, {"and-query":{"queries":[ {"collection-query":{"uri":["mlw2012"]}}, {"term-query":{"text":["fun"]}} ]}}]}}}' \ | |
'http://localhost:8011/v1/search?options=tutorial' |
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
{ | |
"options": { | |
"values": { | |
"collection": { | |
"prefix": "" | |
}, | |
"name": "tag" | |
} | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"values":{"name":"tag","collection":{"prefix":""}}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"values": { | |
"collection": { | |
"prefix": "" | |
}, | |
"name": "tag" | |
} | |
} | |
} |
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
// expose the "contentRating" JSON key range index as "rating" values | |
QueryOptionsHandle options = new QueryOptionsHandle().withValues( | |
qob.values("rating", | |
qob.range( | |
qob.jsonRangeIndex("contentRating", | |
qob.rangeType("xs:int"))))); |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="tag"> | |
<collection prefix=""/> | |
</values> | |
</options> |
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
// create a values definition | |
ValuesDefinition valuesDef = queryMgr.newValuesDefinition("rating", optionsName); |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="tag"> | |
<collection prefix=""/> | |
</values> | |
</options> |
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
{ | |
"values-response": { | |
"metrics": { | |
"aggregate-resolution-time": "PT0.000017S", | |
"total-time": "PT0.001675S", | |
"values-resolution-time": "PT0.000189S" | |
}, | |
"distinct-value": [ | |
{ | |
"_value": "mlw2012", | |
"frequency": 88 | |
}, | |
{ | |
"_value": "photos", | |
"frequency": 140 | |
}, | |
{ | |
"_value": "shakespeare", | |
"frequency": 22 | |
} | |
], | |
"type": "xs:string", | |
"name": "tag" | |
} | |
} |
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
// also retrieve the averages of all ratings | |
valuesDef.setAggregate("avg","median"); |
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
<values-response name="tag" type="xs:string" xmlns="http://marklogic.com/appservices/search"> | |
<distinct-value frequency="88">mlw2012</distinct-value> | |
<distinct-value frequency="140">photos</distinct-value> | |
<distinct-value frequency="22">shakespeare</distinct-value> | |
<metrics> | |
<values-resolution-time>PT0.000195S</values-resolution-time> | |
<aggregate-resolution-time>PT0.000017S</aggregate-resolution-time> | |
<total-time>PT0.001873S</total-time> | |
</metrics> | |
</values-response> |
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
{ | |
"values-response": { | |
"metrics": { | |
"aggregate-resolution-time": "PT0.000017S", | |
"total-time": "PT0.001675S", | |
"values-resolution-time": "PT0.000189S" | |
}, | |
"distinct-value": [ | |
{ | |
"_value": "mlw2012", | |
"frequency": 88 | |
}, | |
{ | |
"_value": "photos", | |
"frequency": 140 | |
}, | |
{ | |
"_value": "shakespeare", | |
"frequency": 22 | |
} | |
], | |
"type": "xs:string", | |
"name": "tag" | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"values":{"name":"uri","uri":null}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/xml" \ | |
-d'<options xmlns="http://marklogic.com/appservices/search"><values name="uri"><uri/></values></options>' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"values": { | |
"name": "uri", | |
"uri": null | |
} | |
} | |
} |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="uri"> | |
<uri/> | |
</values> | |
</options> |
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
{ | |
"options": { | |
"values": { | |
"name": "uri", | |
"uri": null | |
} | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"values":{"name":"company","range":{"type":"xs:string","collation":"http://marklogic.com/collation/","json-key":"affiliation"},"values-option":["frequency-order"]}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="uri"> | |
<uri/> | |
</values> | |
</options> |
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
{ | |
"options": { | |
"values": { | |
"name": "company", | |
"range": { | |
"collation": "http://marklogic.com/collation/", | |
"json-key": "affiliation", | |
"type": "xs:string" | |
}, | |
"values-option": [ | |
"frequency-order" | |
] | |
} | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"values":{"name":"company","range":{"type":"xs:string","collation":"http://marklogic.com/collation/","json-key":"affiliation"},"values-option":["frequency-order"]}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"values": { | |
"name": "company", | |
"range": { | |
"collation": "http://marklogic.com/collation/", | |
"json-key": "affiliation", | |
"type": "xs:string" | |
}, | |
"values-option": [ | |
"frequency-order" | |
] | |
} | |
} | |
} |
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
// print out each size/exposure co-occurrence | |
for (Tuple tuple : tuplesHandle.getTuples()) { |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="company"> | |
<range type="xs:string" collation="http://marklogic.com/collation/"> | |
<json-key>affiliation</json-key> | |
</range> | |
<values-option>frequency-order</values-option> | |
</values> | |
</options> |
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
{ | |
"options": { | |
"values": { | |
"range": { | |
"collation": "http://marklogic.com/collation/", | |
"type": "xs:string", | |
"element": { | |
"ns": "", | |
"name": "SPEAKER" | |
} | |
}, | |
"name": "speaker", | |
"values-option": [ | |
"frequency-order" | |
] | |
} | |
} | |
} |
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
} |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="company"> | |
<range type="xs:string" collation="http://marklogic.com/collation/"> | |
<json-key>affiliation</json-key> | |
</range> | |
<values-option>frequency-order</values-option> | |
</values> | |
</options> |
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
{ | |
"options": { | |
"values": { | |
"range": { | |
"collation": "http://marklogic.com/collation/", | |
"type": "xs:string", | |
"element": { | |
"ns": "", | |
"name": "SPEAKER" | |
} | |
}, | |
"name": "speaker", | |
"values-option": [ | |
"frequency-order" | |
] | |
} | |
} | |
} |
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
QueryOptionsHandle options = new QueryOptionsHandle().withConstraints( | |
// expose the "contentRating" JSON key range index as "rating" values | |
qob.constraint("rating", | |
qob.range( | |
qob.jsonRangeIndex("contentRating", | |
qob.rangeType("xs:int")), | |
Facets.FACETED, | |
FragmentScope.DOCUMENTS, | |
qob.buckets(), | |
"descending")), // highest ratings first | |
// expose the "affiliation" JSON key range index as "company" values | |
qob.constraint("company", | |
qob.range( | |
qob.jsonRangeIndex("affiliation", | |
qob.stringRangeType(QueryOptions.DEFAULT_COLLATION)), | |
Facets.FACETED, | |
FragmentScope.DOCUMENTS, | |
qob.buckets(), | |
"frequency-order"))); // most common values first |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="speaker"> | |
<values-option>frequency-order</values-option> | |
<range type="xs:string" collation="http://marklogic.com/collation/"> | |
<element ns="" name="SPEAKER"/> | |
</range> | |
</values> | |
</options> |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"values":{"name":"speaker","range":{"type":"xs:string","collation":"http://marklogic.com/collation/","element":{"name":"SPEAKER","ns":""}},"values-option":["frequency-order"]}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="speaker"> | |
<values-option>frequency-order</values-option> | |
<range type="xs:string" collation="http://marklogic.com/collation/"> | |
<element ns="" name="SPEAKER"/> | |
</range> | |
</values> | |
</options> |
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
{ | |
"options": { | |
"values": { | |
"range": { | |
"json-key": "contentRating", | |
"type": "xs:int" | |
}, | |
"name": "rating" | |
} | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"values":{"name":"speaker","range":{"type":"xs:string","collation":"http://marklogic.com/collation/","element":{"name":"SPEAKER","ns":""}},"values-option":["frequency-order"]}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"values": { | |
"range": { | |
"json-key": "contentRating", | |
"type": "xs:int" | |
}, | |
"name": "rating" | |
} | |
} | |
} |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="rating"> | |
<range type="xs:int"> | |
<json-key>contentRating</json-key> | |
</range> | |
</values> | |
</options> |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"values":{"name":"rating","range":{"type":"xs:int","json-key":"contentRating"}}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="rating"> | |
<range type="xs:int"> | |
<json-key>contentRating</json-key> | |
</range> | |
</values> | |
</options> |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"values":{"name":"rating","range":{"type":"xs:int","json-key":"contentRating"}}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<!--...--> | |
<aggregate-result name="avg">3.71839080459770115</aggregate-result> | |
<aggregate-result name="median">4</aggregate-result> | |
<!--...--> |
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
"aggregate-result": [ | |
{ | |
"_value": "3.71839080459770115", | |
"name": "avg" | |
}, | |
{ | |
"_value": "4", | |
"name": "median" | |
} | |
] |
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
<!--...--> | |
<aggregate-result name="avg">3.71839080459770115</aggregate-result> | |
<aggregate-result name="median">4</aggregate-result> | |
<!--...--> |
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
"aggregate-result": [ | |
{ | |
"_value": "3.71839080459770115", | |
"name": "avg" | |
}, | |
{ | |
"_value": "4", | |
"name": "median" | |
} | |
] |
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
{ | |
"options": { | |
"values": { | |
"range": { | |
"json-key": "contentRating", | |
"type": "xs:int" | |
}, | |
"name": "rating" | |
} | |
} | |
} |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="rating"> | |
<range type="xs:int"> | |
<json-key>contentRating</json-key> | |
</range> | |
</values> | |
</options> |
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
curl -v -X POST \ --digest --user rest-admin:x \ -H "Content-type: application/json" \ | |
-d'{"options":{"values":{"name":"rating","range":{"type":"xs:int","json-key":"contentRating"}}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<values name="rating"> | |
<range type="xs:int"> | |
<json-key>contentRating</json-key> | |
</range> | |
</values> | |
</options> |
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
{ | |
"options": { | |
"tuples": { | |
"range": [ | |
{ | |
"type": "xs:unsignedLong", | |
"element": { | |
"ns": "http://marklogic.com/filter", | |
"name": "size" | |
} | |
}, | |
{ | |
"collation": "http://marklogic.com/collation/", | |
"type": "xs:string", | |
"element": { | |
"ns": "http://marklogic.com/filter", | |
"name": "Exposure_Time" | |
} | |
} | |
], | |
"name": "size-exposure" | |
} | |
} | |
} |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"values":{"name":"rating","range":{"type":"xs:int","json-key":"contentRating"}}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
{ | |
"options": { | |
"tuples": { | |
"range": [ | |
{ | |
"type": "xs:unsignedLong", | |
"element": { | |
"ns": "http://marklogic.com/filter", | |
"name": "size" | |
} | |
}, | |
{ | |
"collation": "http://marklogic.com/collation/", | |
"type": "xs:string", | |
"element": { | |
"ns": "http://marklogic.com/filter", | |
"name": "Exposure_Time" | |
} | |
} | |
], | |
"name": "size-exposure" | |
} | |
} | |
} |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<tuples name="size-exposure"> | |
<range type="xs:unsignedLong"> | |
<element ns="http://marklogic.com/filter" name="size"/> | |
</range> | |
<range type="xs:string" collation="http://marklogic.com/collation/"> | |
<element ns="http://marklogic.com/filter" name="Exposure_Time"/> | |
</range> | |
</tuples> | |
</options> |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ -d'{"options":{"tuples":{"name":"size-exposure","range":[{"type":"xs:unsignedLong","element":{"name":"size","ns":"http://marklogic.com/filter"}}, {"type":"xs:string","collation":"http://marklogic.com/collation/", "element":{"name":"Exposure_Time","ns":"http://marklogic.com/filter"} } ]}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<tuples name="size-exposure"> | |
<range type="xs:unsignedLong"> | |
<element ns="http://marklogic.com/filter" name="size"/> | |
</range> | |
<range type="xs:string" collation="http://marklogic.com/collation/"> | |
<element ns="http://marklogic.com/filter" name="Exposure_Time"/> | |
</range> | |
</tuples> | |
</options> |
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
curl -v -X POST \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"tuples":{"name":"size-exposure","range":[{"type":"xs:unsignedLong","element":{"name":"size","ns":"http://marklogic.com/filter"}}, {"type":"xs:string","collation":"http://marklogic.com/collation/", "element":{"name":"Exposure_Time","ns":"http://marklogic.com/filter"} } ]}}}' \ | |
'http://localhost:8011/v1/config/query/tutorial' |
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
<!--...--> | |
<tuple frequency="1"> | |
<distinct-value xsi:type="xs:unsignedLong" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">60641</distinct-value> | |
<distinct-value xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">1/100</distinct-value> | |
</tuple> | |
<!--...--> |
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
"tuple": [ | |
{ | |
"distinct-value": [ | |
{ | |
"_value": "60641", | |
"type": "xs:unsignedLong" | |
}, | |
{ | |
"_value": "1/100", | |
"type": "xs:string" | |
} | |
], | |
"frequency": 1 | |
} |
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
<!--...--> | |
<tuple frequency="1"> | |
<distinct-value xsi:type="xs:unsignedLong" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">60641</distinct-value> | |
<distinct-value xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">1/100</distinct-value> | |
</tuple> | |
<!--...--> |
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
"tuple": [ | |
{ | |
"distinct-value": [ | |
{ | |
"_value": "60641", | |
"type": "xs:unsignedLong" | |
}, | |
{ | |
"_value": "1/100", | |
"type": "xs:string" | |
} | |
], | |
"frequency": 1 | |
} |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<!-- expose the "contentRating" JSON key range index as "rating" values --> | |
<constraint name="rating"> | |
<range type="xs:int" facet="true"> | |
<json-key>contentRating</json-key> | |
<!-- highest ratings first --> | |
<facet-option>descending</facet-option> | |
</range> | |
</constraint> | |
<!-- expose the "affiliation" JSON key range index as "company" values --> | |
<constraint name="company"> | |
<range type="xs:string" facet="true" collation="http://marklogic.com/collation/"> | |
<json-key>affiliation</json-key> | |
<!-- most common values first --> | |
<facet-option>frequency-order</facet-option> | |
</range> | |
</constraint> | |
</options> |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"range": { | |
"json-key": "contentRating", | |
"type": "xs:int", | |
"facet-option": "descending" | |
}, | |
"name": "rating" | |
}, | |
{ | |
"range": { | |
"collation": "http://marklogic.com/collation/", | |
"json-key": "affiliation", | |
"type": "xs:string", | |
"facet-option": "frequency-order" | |
}, | |
"name": "company" | |
} | |
] | |
} | |
} |
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
<options xmlns="http://marklogic.com/appservices/search"> | |
<!-- expose the "contentRating" JSON key range index as "rating" values --> | |
<constraint name="rating"> | |
<range type="xs:int" facet="true"> | |
<json-key>contentRating</json-key> | |
<!-- highest ratings first --> | |
<facet-option>descending</facet-option> | |
</range> | |
</constraint> | |
<!-- expose the "affiliation" JSON key range index as "company" values --> | |
<constraint name="company"> | |
<range type="xs:string" facet="true" collation="http://marklogic.com/collation/"> | |
<json-key>affiliation</json-key> | |
<!-- most common values first --> | |
<facet-option>frequency-order</facet-option> | |
</range> | |
</constraint> | |
</options> |
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
{ | |
"options": { | |
"constraint": [ | |
{ | |
"range": { | |
"json-key": "contentRating", | |
"type": "xs:int", | |
"facet-option": "descending" | |
}, | |
"name": "rating" | |
}, | |
{ | |
"range": { | |
"collation": "http://marklogic.com/collation/", | |
"json-key": "affiliation", | |
"type": "xs:string", | |
"facet-option": "frequency-order" | |
}, | |
"name": "company" | |
} | |
] | |
} | |
} |
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
curl -v -X PUT \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"rating","range":{"type":"xs:int","json-key":"contentRating","facet-option":"descending"}}, {"name":"company","range":{"type":"xs:string","collation":"http://marklogic.com/collation/","json-key":"affiliation","facet-option":"frequency-order"}} ]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial2' |
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
"facets": { | |
"rating": { | |
"facetValues": [ | |
{ | |
"count": 61, | |
"name": "5" | |
}, | |
{ | |
"count": 54, | |
"name": "4" | |
}, | |
{ | |
"count": 34, | |
"name": "3" | |
}, | |
{ | |
"count": 11, | |
"name": "2" | |
}, | |
{ | |
"count": 2, | |
"name": "1" | |
}, | |
{ | |
"count": 12, | |
"name": "0" | |
} | |
], | |
"type": "xs:int" | |
}, | |
"company": { | |
"facetValues": [ | |
{ | |
"count": 38, | |
"name": "MarkLogic" | |
}, | |
{ | |
"count": 2, | |
"name": "Avalon Consulting, LLC" | |
}, | |
{ | |
"count": 2, | |
"name": "Overstory, Ltd." | |
} | |
], | |
"type": "xs:string" | |
} | |
} |
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
curl -v -X PUT \ | |
--digest --user rest-admin:x \ | |
-H "Content-type: application/json" \ | |
-d'{"options":{"constraint":[{"name":"rating","range":{"type":"xs:int","json-key":"contentRating","facet-option":"descending"}}, {"name":"company","range":{"type":"xs:string","collation":"http://marklogic.com/collation/","json-key":"affiliation","facet-option":"frequency-order"}} ]}}' \ | |
'http://localhost:8011/v1/config/query/tutorial2' |
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
"facets": { | |
"rating": { | |
"facetValues": [ | |
{ | |
"count": 61, | |
"name": "5" | |
}, | |
{ | |
"count": 54, | |
"name": "4" | |
}, | |
{ | |
"count": 34, | |
"name": "3" | |
}, | |
{ | |
"count": 11, | |
"name": "2" | |
}, | |
{ | |
"count": 2, | |
"name": "1" | |
}, | |
{ | |
"count": 12, | |
"name": "0" | |
} | |
], | |
"type": "xs:int" | |
}, | |
"company": { | |
"facetValues": [ | |
{ | |
"count": 38, | |
"name": "MarkLogic" | |
}, | |
{ | |
"count": 2, | |
"name": "Avalon Consulting, LLC" | |
}, | |
{ | |
"count": 2, | |
"name": "Overstory, Ltd." | |
} | |
], | |
"type": "xs:string" | |
} | |
} |
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