如何将xhtml文档作为文本加载并在marklogic中搜索关键字

时间:2015-01-07 06:41:10

标签: xquery marklogic xquery-3.0 adhoc-queries cts-search

我已经在marklogic中加载了XHTML文件。但需要对属性,元素和文本执行搜索。 所以我需要将文档作为文本获取/加载并对文档执行搜索。

以下是XHTML文件。

            <?xml version="1.0" encoding="UTF-8"?>
    <html xmlns="http://www.w3.org/1999/xhtml">
        <meta>
            </meta>
        <body class="Default">

        </body>
    </html>

Using below code I am ble to save text file but it will aloow to save (>0.2KB )small size file. I need to save upto 1 to 50MB files in marklogic DB.

Using below code I am able to save file as text but big file not able to save.
 ContentCreateOptions createOptions = ContentCreateOptions.newTextInstance();

 Content content = ContentFactory.newContent("/"+uID,filetext, createOptions);

 mlSession.insertContent(content);

1 个答案:

答案 0 :(得分:0)

仍然不太确定这背后的用例,但是你走了:

如果您真的想要一起搜索元素名称,属性和文本的全文,而不受歧视,最好在摄取时将其作为文本插入。例如:

xdmp:document-insert(
    "/my.xhtml",
    text {
        xdmp:quote(
            <html xmlns="http://www.w3.org/1999/xhtml">
                ...
            </html>
        )
    }
)

或者:

xdmp:document-load(
    "/server/path/to/my.xhtml",
    <options xmlns="xdmp:document-load">
        <format>text</format>
    </options>
)

之后你就可以做到:

cts:search(collection(), "mytagorattrorterm")

或者你可以在执行cts之前使用xdmp:quote:contains或fn:contains,但是它的扩展非常糟糕,所以你最好只在一个或几个文档上同时进行。

HTH!

相关问题