繁体   English   中英

Marklogic REST API-从文档中提取数据

[英]Marklogic REST API - Extract data from documents

我是MarkLogic的新手,我正尝试使用搜索API从文档中提取信息。 我的文件采用以下格式。

<nitf>
<head>
<title>ABC</title>
</head>
...
...
</nitf>

我只想在结果中显示与搜索查询匹配的文档的标题,即搜索API必须仅返回匹配文档的标题。 我浏览了文档并尝试了其他操作,例如@ehennum建议的查询选项,但没有效果。 任何帮助都会很棒。 谢谢!

克里希纳,听起来您根本不想要摘录,因此您应该关闭摘录

<search:transform-results apply="empty-snippet"/>

然后要获取标题,请使用extract-metadata

<search:extract-metadata>
  <search:qname elem-ns="" elem-name="title"/>
</search:extract-metadata>

作为Dave好的建议的脚注,MarkLogic 7提供了“示例查询”作为简单的搜索界面。 请参见:

http://docs.marklogic.com/REST/POST/v1/qbe

http://docs.marklogic.com/guide/search-dev/qbe#id_54044

特定查询如下所示:

<q:qbe xmlns:q="http://marklogic.com/appservices/querybyexample">
  <q:query>
    ... your query by example ...
  </q:query>
  <q:response>
    <q:snippet><q:none/></q:snippet>
    <q:extract><title/></q:extract>
  </q:response>
</q:qbe>

如果我没记错的话,NITF不会使用名称空间,但是如果使用了名称空间,则必须使用标题限定标题。

为了扩展@ dave-cassel的精确答案,从MarkLogic版本8开始,不建议使用<search:extract-metadata>选项,而应使用search:extract-document-data -直接从API文档中删除:

<search:extract-document-data selected="include">
  <search:extract-path xmlns="">/userName</search:extract-path>
</search:extract-document-data>

更多: https//docs.marklogic.com/searchsearch#opt-extract-document-data

暂无
暂无

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

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