Created
October 23, 2012 20:55
-
-
Save evanlenz/3941495 to your computer and use it in GitHub Desktop.
Code examples for article http://developer.marklogic.com/blog/utilizing-path-indexes-in-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
<widget xmlns="http://example.com/widgets"> | |
<part count="30"> | |
<name>Thingamajig</name> | |
</part> | |
</widget> |
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 \ | |
'<widget xmlns="http://example.com/widgets"> | |
<part count="30"> | |
<name>Thingamajig</name> | |
</part> | |
</widget>' \ | |
'http://localhost:8011/v1/documents?uri=/widget.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
{ | |
"options": { | |
"constraint": { | |
"name": "part-count", | |
"range": { | |
"type": "xs:int", | |
"path-index": { | |
"text": "/w:widget/w:part/@count" | |
} | |
} | |
}, | |
"values": { | |
"name": "part-count", | |
"range": { | |
"type": "xs:int", | |
"path-index": { | |
"text": "/w:widget/w:part/@count" | |
} | |
} | |
} | |
} | |
} |
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":"part-count","range":{"type":"xs:int","path-index":{"text":"/w:widget/w:part/@count"}}},"values":{"name":"part-count","range":{"type":"xs:int","path-index":{"text":"/w:widget/w:part/@count"}}}}}' \ | |
'http://localhost:8011/v1/config/query/path-example' |
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
{ | |
"namespace-bindings": [ | |
{ | |
"prefix": "w", | |
"uri": "http://example.com/widgets" | |
} | |
] | |
} |
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'{"namespace-bindings":[{ "prefix" : "w", "uri" : "http://example.com/widgets" }]}' \ | |
'http://localhost:8011/v1/config/namespaces' |
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> | |
<range-constraint-query> | |
<constraint-name>part-count</constraint-name> | |
<text>30</text> | |
</range-constraint-query> | |
<directory-query> | |
<uri>/special-widgets/</uri> | |
<infinite>true</infinite> | |
</directory-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
temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment