0

在搜索 SPFolders 而不是文件时,或者在搜索自定义内容类型时,使用 CAML 和 SPQuery 进行搜索似乎不适用于自定义元数据。我一直在使用 U2U 来测试各种查询,但没有任何结果。该文档的主题不是很完整,谷歌也没有提供帮助。

在一项测试中,我试图在树中找到任何属于特定自定义内容类型的 SPFolders。如果我正确理解 CAML,这应该有效:

<Query>
    <Where>
        <Eq>
            <FieldRef Name='ContentType' />
            <Value Type='Text'>CustomTypeName</Value>
        </Eq>
    </Where>
</Query>

在另一个测试中,我试图找到任何将自定义元数据属性设置为特定值的 SPFolder。

<Query>
    <Where>
        <Eq>
            <FieldRef Name='CustomProp' />
            <Value Type='Text'>SpecificPropValue</Value>
        </Eq>
    </Where>
</Query>

在这两种情况下,我都将搜索的根设置为包含文件夹的文档库,其中包含文件夹,其中包含文件夹(唷。)此外,我将 SPQuery 设置为递归搜索。

我正在搜索的文件夹向下两步是树中最远的文件夹。我不想一直迭代以手动找到有问题的文件夹。

编辑知道我同时使用带有 SPQuery 作为参数的 SPList.GetItems 和带有 SPSiteDataQuery 作为参数的 SPWeb.GetSiteData 也可能会有所帮助。目前,这些查询中的任何一个的搜索集中似乎都不包含文件夹。

任何帮助将不胜感激。

4

2 回答 2

2

After more research, I'm answering my own question.

Apparently the methods that I'm using to query don't return SPFolders as items in the result set. Only list items are returned, basically just documents.

My fix was to execute a CAML query for all the documents with a certain metadata tag/value, and then using the parent folder of the first one as the representative folder for the set. Works well enough for my needs.

于 2008-10-07T20:12:20.767 回答
1

尝试将SharePoint 管理器Stramit CAML 查看器添加到您的工具集中。

I have found both to be very important for figuring out CAML problems.

于 2008-10-06T20:10:44.217 回答