SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

SPSiteDataQuery limited to 10 document libraries or lists
Technorati Tags:

In previous posts I talked about the pitfalls of searching in WSS or MOSS. I wanted to report one more limitation we have discovered when doing cross-list searches in WSS using the SPSiteDataQuery object. The SPWeb.GetSiteData method is used to execute cross-list searches within a site collection. This method takes a SPSiteDataQuery object which contains properties which need to be populated prior to sending it to the GetSiteData method. Using CAML (Collaborative Application Markup Language) you can construct a cross-list query. Subsets of the CAML query are then used to set the properties of the SPSiteDataQuery object, for example the Query property.

<Caml>
    <Query>
        <Where>
            <And>
                <And>
                    <Eq>
                        <FieldRef Name="InvoiceNumber"/>
                        <Value Type="Number">125555</Value>
                    </Eq>
                    <Eq>
                        <FieldRef Name="MNEMONIC"/>
                        <Value Type="Text">AAA</Value>
                    </Eq>
                </And>
                <Neq>
                    <FieldRef Name="FSObjType"/>
                    <Value Type="Lookup">1</Value>
                </Neq>
            </And>
        </Where>
    </Query>
    <ViewFields>
        <FieldRef Name="FileRef" Nullable="TRUE"/>
        <FieldRef Name="EncodedAbsUrl" Nullable="TRUE"/>
        <FieldRef Name="FileDirRef" Nullable="TRUE"/>
        <FieldRef Name="Title" Nullable="TRUE"/>
        <FieldRef Name="InvoiceNumber" Nullable="TRUE"/>
        <FieldRef Name="MNEMONIC" Nullable="TRUE"/>
    </ViewFields>
    <QueryOptions/>
    <Lists ServerTemplate="101"/>
    <Webs Scope="Recursive"/>
</Caml>

 

This query will not return all the results if your site collection has more than 10 document libraries and any of the columns are in different order in the document libraries. This applies to lists also. Microsoft has confirmed this to be a bug. According to Microsoft when the site collection contains more than 10 document libraries the internal code escalates to use a temporary table. If document library(1).Column1 is not the same physical column as document library(2).Column1 then results are incorrect. Microsoft does not plan to fix this in SP1 but hopefully in SP2.

 

Workarounds?

You can make sure you limit your site collection to 10 document libraries and 10 lists. Alternatively, you can strictly control column creation within your site collections via security and the use of a well planned content type strategy (http://technet2.microsoft.com/Office/f/?en-us/library/63bb092a-00fe-45ff-a4b8-d8be998d1a3c1033.mspx). The bottom line is to not  let your document library metadata columns get out of order. Finally, if you are developing on MOSS use the Microsoft.Office.Server.Search.KeywordQuery or FullTextSQLQuery classes to do your searching. If you have only a WSS 3.0 install you could use the Microsoft.SharePoint.Search.Query.KeywordQuery or FullTextSQLQuery classes. Unfortunately, you are limited to built in metadata searching and custom metadata is not supported. Ahhh, but there is a way around this which could be in a future post.


Posted 07-24-2007 11:28 AM by steveC

Comments

Mirrored Feeds wrote SPSiteDataQuery limited to 10 document libraries or lists
on 07-24-2007 11:48 AM

Technorati Tags: WSS SharePoint Search In previous posts I talked about the pitfalls of searching in

Darrin Bishop wrote SPSiteDataQuery - Greater Than 10 Lists Issue
on 07-24-2007 2:19 PM

SPSiteDataQuery - Greater Than 10 Lists Issue

Sharepoint 2007 link love 07-25-2007 at Virtual Generations wrote Sharepoint 2007 link love 07-25-2007 at Virtual Generations
on 07-25-2007 3:34 AM

Pingback from  Sharepoint 2007 link love 07-25-2007 at  Virtual Generations

mdp wrote re: SPSiteDataQuery limited to 10 document libraries or lists
on 07-25-2007 11:47 PM

You should be able to get around this by including a Lists node, with the lists node, you can specify a MaxListLimit of 0, which means unlimited lists:

<Lists MaxListLimit="0" />

Out of the box, it is supposed to default to 1000, but I'm not sure if that is the case after I've gotten errors about too many lists with smaller sites.

More detail here at my blog

www.sharepointblogs.com/.../spsitedataquery-the-query-cannot-be-completed-because-the-number-of-lists-in-the-query-exceeded-the-allowable-limit.aspx

steveC wrote re: SPSiteDataQuery limited to 10 document libraries or lists
on 07-26-2007 10:09 AM

This is not a workaround. Microsoft has confirmed this as a bug QFE19490 now with the possibility that it will be included in the SP1 release.

MikeBass wrote re: SPSiteDataQuery limited to 10 document libraries or lists
on 08-08-2007 9:04 AM

Great heads-up! I was going to be relying on this approach for more than 10 lists. Good to know that there are issues now.

"Ahhh, but there is a way around this which could be in a future post"... Is there any way you could hint at the workaround to point me in the right direction?

Thanks

smc750 wrote re: SPSiteDataQuery limited to 10 document libraries or lists
on 08-23-2007 12:05 PM

Microsoft has informed us a hotfix will be coming around October 12.

KrisA wrote re: SPSiteDataQuery limited to 10 document libraries or lists
on 09-18-2007 8:35 AM

You mentioned bug QFE19490 - do you happen to have a link? I can't seem to find it.

steveC wrote re: SPSiteDataQuery limited to 10 document libraries or lists
on 10-04-2007 12:55 PM

Microsoft has informed us yesterday that there will not be a fix for this until SP2.

SharePoint FieldNotes (Steve Curran) wrote SPSiteDataQuery limited to 10 document libraries work around
on 11-19-2007 4:26 PM

Technorati Tags: WSS SharePoint Search In one of my last posts I talked about the limitations of using

Sam Mitchell wrote re: SPSiteDataQuery limited to 10 document libraries or lists
on 11-21-2007 11:34 AM

I have a scenario where I need to get all the items on the basis of a specific server template. I have created a scenario where I have 15 document libraries in 4 different sites of a site collection and SPSiteDataQuery object is returning correct result set every time.

I would really appreciate if you please provide the exact scenario (Site Collection template, Site template within collection, specific column type etc) that generates this issue so we can counter it.

Thanks

Susan Lennon wrote re: SPSiteDataQuery limited to 10 document libraries or lists
on 01-15-2008 9:33 AM

Is it pssible the Content Query Web Part has the same issue?  We have CQWPs that worked for months that all of a sudden are failing and not returning data - when pointed at the site collection.  When pointed at a site (and it's subsites), they work fine.  I'm wondering if we hit some kind of internal limit.  Has anyone else seen this?

SharePoint FieldNotes (Steve Curran) wrote SPSiteDataQuery limited to 10 document libraries confirmed by Microsoft
on 01-25-2008 3:07 PM

Technorati Tags: WSS SharePoint Search In previous posts I talked about the inaccurate results received

Eli Robillard wrote re: SPSiteDataQuery limited to 10 document libraries or lists
on 01-29-2008 2:36 PM

Susan: yes. The CQWP uses a SPSiteDateQuery to return results and is affected by the issue.

You can identity and potentially repair issues with this CodePlex tool: www.codeplex.com/SPCQOptimizer

"Sharepoint User Group" on LinkedIn wrote SPSiteDataQuery and 10 Lists.
on 03-13-2008 2:36 AM

SPSiteDataQuery and 10 Lists.

Damien wrote re: SPSiteDataQuery limited to 10 document libraries or lists
on 03-18-2009 12:12 PM

Here is how to build a link based on the Url retreived in the FileRef column:

string [] slipFileRef = row["FileRef"].ToString().Split('#');

string fullUrl = "<a href=\"" + site.MakeFullUrl(slipFileRef[1].Remove(slipFileRef[1].LastIndexOf('/') + 1) + "DispForm.aspx?ID=" + slipFileRef[0].TrimEnd(';')) + "\">Test this link</a>";

Hope this helps,

Damien

JohnH wrote re: SPSiteDataQuery limited to 10 document libraries or lists
on 05-21-2009 8:29 AM

This appears to be fixed in the Infra Update BTW

support.microsoft.com/.../953749

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.