简体   繁体   English

将MarkLogic xcc cts查询转换为发布cts查询

[英]Convert MarkLogic xcc cts queryto post cts query

Marklogic 9 and above no longer supports xcc connection for.NET applications and instead rest api shall be used. Marklogic 9及更高版本不再支持.NET应用程序的xcc连接,而应使用rest api。

I have been working on a POC and got my db instances exposed through a REST API creating REST API instances for each db. 我一直在研究POC,并通过REST API公开了我的数据库实例,并为每个数据库创建了REST API实例。 I have also been able to do simple search queries using GET. 我还能够使用GET进行简单的搜索查询。 I have also used PUT and DELETE. 我还使用了PUT和DELETE。

My problem is converting existing 140+ cts queries to xml body. 我的问题是将现有的140多个cts查询转换为xml正文。 There is an example here but uses a simple cts query, I would like some help on converting more complex queries into xml body - so I can use those against the api I have created. 这里有一个示例但是使用了一个简单的cts查询,我希望获得一些将更复杂的查询转换为xml主体的帮助-这样我就可以针对自己创建的api使用这些查询。

Fore example: 前例:

How could I write this cts query in xml? 如何在xml中编写此cts查询?

<ArrayOfRecord>
{{
cts:search(collection('Records{0}')/Record,
cts:and-query((
cts:element-range-query(xs:QName('CreatedOn'), '>=', xs:dateTime('{1}')),
cts:element-range-query(xs:QName('CreatedOn'), '<=', xs:dateTime('{2}')),
cts:path-range-query('/Record/IsLatestVersion', '=', 
'{3}')additionalQueries)))   
}}
</ArrayOfRecord>

Thanks 谢谢

What you showed is a search, not just the cts:query , but if you just want to serialize a cts:query to XML, you can use a trick like this: <wrapper>{your query constructor here}</wrapper> . 您显示的是一个搜索,不仅是cts:query ,而且如果您只是想将cts:query序列化为XML,则可以使用这样的技巧: <wrapper>{your query constructor here}</wrapper>

For example: 例如:

xquery version "1.0-ml";
<wrapper>{cts:word-query("foo")}</wrapper>/*

Another possibility, which perhaps is too similar to Dave Cassel's suggestion for you, would be to use the REST Client API eval endpoint. 另一个可能与Dave Cassel对您的建议太相似的可能性是使用REST Client API eval端点。 You can use it to execute ad hoc XQuery (or Server-Side JavaScript), just as XCC enabled. 就像启用了XCC一样,您可以使用它来执行临时XQuery(或服务器端JavaScript)。 Take a look at this: http://docs.marklogic.com/REST/POST/v1/eval 看一下这个: http : //docs.marklogic.com/REST/POST/v1/eval

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM