1

How do you use a KeywordQuery to search for "last modified by" and "last modified date"?

This is for SharePoint 2010 Server, with publishing pages and document libraries, so "enterprise search". I'm currently using the query like so:

new KeywordQuery(SPContext.Current.Site)
{
    QueryText = "query",
    // ...
};
1

If you use a KeywordQuery, both of these are easily searched upon.

For "last modified by", you can simply add:

and Author:"domain\user"

...to the Query. This will only return items who were last updated by domain\user.

For "last modified date", this is most easily filtered upon when the search results are already gathered, by using a RowFilter on a DataView made from the DataTable returned by the KeywordQuery:

dataView.RowFilter = "write <= '1989-12-24'";

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.