I'm creating a webpart which derives from Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart and the purpose of this webpart is to find all documents modified by current user.

I've figured as much as to use the QueryManager.UserQuery to some extent but I cannot find any guidance on how the syntax works and what properties are available.

Does anybody have some examples?

  • What version of SharePoint? Jan 7 '14 at 13:39
  • @MatthewMcDermott 2010
    – user2536
    Jan 7 '14 at 13:50

For a such scenario the following approaches could be considered:

Override Query

    public class MyAggregatedDocuments : Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart

        protected override void ConfigureDataSourceProperties()
            // only perform actions when we are trying to show search results
            // i.e. not when you're in Design Mode
            if (this.ShowSearchResults)
                // call the base web part method

                // get the data source object
                CoreResultsDatasource dataSource = this.DataSource as CoreResultsDatasource;

                // override the query being executed: Documents modified by current user
                dataSource.Query = string.Format("IsDocument:1 AND Author:\"{0}\"",SPContext.Current.Web.CurrentUser.Name);


Leverage CoreResultsWebPart properties

The following properties could be used to specify query:




crwp.AppendedQuery = string.Format("IsDocument:1 AND Author:\"{0}\"",SPContext.Current.Web.CurrentUser.Name);

To construct a query by Modified Date it is assumed that Author managed property is used.

Regarding query syntax, follow Keyword Query Language (KQL) syntax reference for a more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy