Marklogic 8 XML搜索 [英] Marklogic 8 xml search

查看:70
本文介绍了Marklogic 8 XML搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个xml,如下所示:

Suppose I have a xml as below:

<xx>
    <yy>
        <name>A</name>
        <value>1</value>
    </yy>

    <yy>
        <name>A</name>
        <value>2</value>
    </yy>

    <yy>
        <name>B</name>
        <value>1</value>
    </yy>
</xx>

现在,我想查找是否存在名称为A且值为1的'yy'.因此,此处的匹配内容为:

Now I want to find if any 'yy' is present with name as A and value as 1. So here the matching content would be:

<yy>
    <name>A</name>
    <value>1</value>
</yy>

我正在尝试通过 REST 调用,qbe GET 请求来执行此操作,但无法执行此操作.有人可以帮助我吗?

I am trying to do this by REST call,qbe GET request but not able to do it. Can some one help me out using:

/v1/qbe
or
/v1/search

推荐答案

使用/v1/search API,您将需要使用自定义搜索选项来实现此目的.

With the /v1/search API you'll need to use custom search options to achieve this.

要将自定义搜索选项上传到MarkLogic:

To upload custom search options to MarkLogic: http://developer.marklogic.com/learn/rest/custom-search#search-using-an-element-value-constraint

您的搜索选项将根据您创建的索引来定义搜索约束.您的搜索选项应如下所示:

Your search options will define constraints for your search based on the indexes you created. Your search options should look like this:

<options xmlns="http://marklogic.com/appservices/search">
  <constraint name="yy">
    <element-query name="yy" ns="" />
  </constraint>
  <constraint name="name">
    <value>
      <element ns="" name="name"/>
    </value>
  </constraint>
  <constraint name="value">
    <value>
      <element ns="" name="value"/>
    </value>
  </constraint>
</options>

假设您将这些选项上传为"mySearchOptions".

Let's say you upload these options as "mySearchOptions".

最后,您可以发出此GET请求以获取所需的搜索结果:

Finally, you can make this GET request to get the search results you want:

http: //localhost:REST_SERVER_PORT/v1/search?q = yy%3A(name%3Aa%20AND%20value%3A1)& options = mySearchOptions

这篇关于Marklogic 8 XML搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆