簡體   English   中英

如何將xhtml文檔作為文本加載並在marklogic中搜索關鍵字

[英]How to load the xhtml document as a text and search the keyword in marklogic

我已經在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);

仍然不太確定背后的用例,但是您可以執行以下操作:

如果您真的想完整地搜索元素名稱,屬性和文本的全文,最好不要在提取時將其作為文本插入。 例如,類似:

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:contains或fn:contains之前使用xdmp:quote,但是伸縮性很差,因此最好只在一個或幾個文檔上同時執行。

HTH!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM