Thursday, November 22, 2007

SPQuery inside a foreach bucle

Today I have found a strange behavior of the SPQuery class. My code has the following structure:


SPList list = web.Lists["MyList"];
SPQuery query = new SPQuery();
foreach (DataRow row in table.Rows)
{
query.Query = "<Where>Some CAML Query with a row dependant condition</Where>";
SPListItemCollection items = list.GetItems(query);

}

After the first iteration, the SPListItemCollection items always contains the same items, although the Query property of the query has been changed in the bucle. To resolve it I have putted the initialization of the SPQuery inside the bucle:


SPList list = web.Lists["MyList"];
foreach (DataRow row in table.Rows)
{
SPQuery query = new SPQuery();
query.Query = "<Where>Some CAML Query with a row dependant condition</Where>";
SPListItemCollection items = list.GetItems(query);

}

And now all works normally.

Wednesday, November 7, 2007

A button to submit content to SharePointPedia

Try it on my page. With this simple code on your page you can add a button to submit the content to the SharePointPedia:

<input alt="Submit to SharePointPedia.com" name="Button1" type="image" src="http://sharepoint.microsoft.com/Pedia/PublishingImages/SPP/topbar_logo_spd.gif" value="Submit to SharePointPedia.com" onclick="javascript:location.href='http://sharepoint.microsoft.com/pedia/pages/post.aspx?url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title)" />

Enjoy it!

Monday, November 5, 2007

An easy way to change the SharePoint index file’s location

This solution is valid for these scenarios where a full crawl is not a problem. In these cases you can move the index stopping the Office SharePoint Search Service and starting it again. In the form to start it you will find a textbox to indicate the new location of the index file. Then you will need to assign the index server for each SSP and start a full crawl for each content source. Remember that during the processes the search results will be incomplete.

After that I have some questions:

  • How could we change the default index location without reinstalling SharePoint?
  • In the default index location there are some folders with text files. Which is their function? I think they are related with the SQL Search, but I am not sure.

To understand the key concepts of the search infrastructure I have read the chapter 17 (specially the page Choosing a Search Implementation Topology Model) of the Microsoft Office SharePoint Server 2007 Administrator's Companion.

Related links:
https://blogs.pointbridge.com/Blogs/robinson_will/Lists/Posts/Post.aspx?ID=21 (move the index without a full crawl)

 
Online Visitors