如何将给定文本搜索到marklogic XHTML文件中,例如clt + f [英] How to search the given text into marklogic XHTML file, like clt+f

查看:93
本文介绍了如何将给定文本搜索到marklogic XHTML文件中,例如clt + f的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面的XHTML文件中使用URI(/54ab8c234f3c8ce1f5c30ddc)将其保存在marklogic中.

I have below XHTML file saved in the marklogic with the URI(/54ab8c234f3c8ce1f5c30ddc).

我需要根据字符串(如果它是标记名或属性名或XHTML中的文本)搜索Marklogic DB.

I need to search the Marklogic DB based on the string (if it is tag name or attribute name or text in the XHTML).

我只能搜索任一文本的属性.但无法一次全部搜索.

I am able to search only text either attribute. But not able to search at a time all.

注意:如果我传递"SS_Default"(它是一个属性值)字符串,它将返回marklogic的URI,或者如果我传递"META"(它是标记名称),则它应返回相应的URI,或者如果我传递传递"Narrowed by"(它是一个文本),它应该返回对应文件的URI.

Note: if I pass "SS_Default"(it is a attribute value) string it will return the URI of marklogic or if I pass the "META" (it is a tag name) it should return the corresponding URIs or if I pass "Narrowed by"(it is a text) it should return the URI of corresponding file.

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

        </body>
    </html>

推荐答案

您尝试执行的搜索类型通常彼此不同,因为它们是不同类型的数据.例如,如果您要搜索元"并查找包含该元素的文档,那么您正在查询结构.您可以在MarkLogic中通过以下查询来做到这一点:

The kinds of searches you are trying to do are typically done differently from each other, as they are different types of data. For instance, if you want to search for "meta" and find documents that have that element, you are querying the structure. You can do that in MarkLogic with this kind of query:

cts:uris((), (), cts:element-query(xs:QName("meta"), ()))

当您要搜索缩小范围"时,这只是文本,简洁明了:

When you want to search for "narrowed by", that's just text, nice and simple:

cts:uris((), (), "narrowed by")

如果要在属性内搜索,通常可以通过指定要搜索的属性来完成:

If you want to search within attributes, that's typically done by specifying the attribute you want to search for:

cts:uris((), (), cts:attribute-value-query(xs:QName("body"), xs:QName("class"), "SS_Default"))

如果您想将它们结合起来,可以运行一个或查询.我建议仔细检查您计划运行的查询类型,并查看是否可以通过这种方式对它们进行细分.正如mholstege指出的那样,您可以将文档以文本形式加载,并且能够以字符串形式搜索所有内容,但是您会在结构中损失很多价值,因此最好退一步考虑一下是否真的需要运行那些以相同的方式查询.

If you wanted to combine those, you could run an or-query. I suggest looking through the types of queries you plan to run and see whether they can be segmented this way. As mholstege notes, you could load the document as text and be able to search everything as strings, but you'd lose a lot of value in the structure, so it's probably better to step back and think about whether you really need to run those queries the same way.

这篇关于如何将给定文本搜索到marklogic XHTML文件中,例如clt + f的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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