We are trying to use SearchQuery to get a list of components inside our C# TBB. Below is the code:

SearchQuery sq = new SearchQuery(session);
sq.IsPublished = true;
//API Limitation, only support 1 keywords
DateTime? after = DateTime.Now.AddDays(-100);
DateTime? before = DateTime.Now.AddDays(2);
sq.ModifiedAfter = after;
sq.ModifiedBefore = before;
sq.SearchIn = pub;
IEnumerable<IdentifiableObject> result = sq.GetResults();

But we get the following errors:

Unable to process the Search Request. Invalid search query:  

RepositoryId:tcm\:0\-3\-1 OR RepositoryId:tcm\:0\-4\-1 
OR RepositoryId:tcm\:0\-5\-1 OR RepositoryId:tcm\:0\-6\-1 
OR RepositoryId:tcm\:0\-7\-1 OR RepositoryId:tcm\:0\-21\-1) 
AND (ItemType:16) 
AND ModificationDate:[2013-03-05T21:23:01Z TO 2013-06-15T21:23:01Z] 
AND (CatchAllXml:"href tcm\\:*\-57814\-1024")

If we remove the Modify time related code it will works fine: *sq.ModifiedAfter = after; sq.ModifiedBefore = before;*

I notice inside the error message, the date-related script seems to be not the same as the others, it wasn't wrapped by parentheses.

What might be the cause of this?

1 Answer 1


If you're doing rendering via a CM API, i.e. at publish time, does it make sense to query for items that may be modified in the future (that is 'before AddDays(2)')? This is a statement that can never be true because NOW is the latest modified date that is possible when querying during static rendering/publishing.

I suggest either setting both, 'after' and 'before', to be <=NOW or setting only 'after' leaving 'before' at its default of NOW.

  • We tried all situation, like only Modified before, only Modified after, add both, search it between 4/2013 to 5/3013. It doesn't care what you input. If you use one of these criteria, this error will popup.
    – qchen01
    Jun 14, 2013 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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