Searching multiple scopes with All Content and an exclude rule returns "The search query is malformed" RRS feed

  • Question

  • Hi,

    I have two scopes which are being used in an Advanced Search Box web part. The two scopes contain the following rules:

        rule: All Content
        behavior: Include

        rule: ContentSource = MyContentSource
        behavior: Include
    In the Advanced Search Box web part for the option "Only the scope(s)" I am able to check both scopes and perform a successful search*.

    For Scope1 a new rule is added that excludes a content source; after adding this exclude rule I am unable to search both scopes together.  The web part outputs the string "Your search cannot be completed because of a service error. Try your search again or contact your administrator for more information"

    The SharePoint logs contains: "Microsoft.Office.Server.Search.Query.QueryMalformedException: Your query is malformed. Please rephrase your query" thrown from Microsoft.Office.Server.Search.Query.FullTextSqlQuery.Execute.

    I tested with the web service /_vti_bin/search.asmx and executed the following search query:

    using (search.QueryService qs = new WebService.search.QueryService())  
        qs.Credentials = System.Net.CredentialCache.DefaultCredentials;  
        StringBuilder query = new StringBuilder();  
        query.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");  
        query.Append("<QueryPacket xmlns=\"urn:Microsoft.Search.Query\" Revision=\"1000\">");  
        query.Append("<Query domain=\"QDomain\">");  
        query.Append("<QueryText language=\"en-US\" type=\"MSSQLFT\">");  
        query.Append("SELECT ");  
        query.Append("Title, Path, Description, Write, Rank, Size ");  
        query.Append("FROM SCOPE() ");  
        query.Append("WHERE ");  
        query.Append("((\"Scope\"='Scope1') OR (\"Scope\"='Scope2')) ");  
        query.Append("AND FREETEXT(DEFAULTPROPERTIES,'jpg')");  
        string results = qs.Query(query.ToString());  
        using (System.IO.StreamWriter file = new System.IO.StreamWriter("SearchResults.xml"))  

    And got the same results:

    <Response domain="QDomain">  
    Your query is malformed. Please rephrase your query.  

    The condition that triggers the failed search is when a scope contains the "All Content" rule and a rule that performs an exclude on a content source or a content class property, and more than one scope is used in the search query.  Having exclude rules in scopes that do not have the "All Content" rule will not trigger this problem.

    Is a scope with the rules including All Content and then excluding specific content sources supported?

    The way I see to work around this problem so my users do not see this error is to create a new display group used for the Advanced Search Box web part that does not include the scope using the "All Content" rule.

    I'm running MOSS 20007 version


    * searching against multiple scopes where one contains the All Content rule might not make much sense; with the current display groups our site has from user testing users have checked all the scopes available and run into this problem.

    Tuesday, September 2, 2008 11:39 AM

All replies

  • Hi,

      Were you able to fix the problem? I am having the same issue (2 scopes, 1 with 'All Content'). The query generating algorithm is generic and I have about ~120 scopes. So, excluding may not the option for me. Is there anyway to instruct the MOSS query engine that if there is an 'All Content' scope, ignore the other scopes?

    I would appreciate any help...

    Wednesday, January 14, 2009 7:31 PM
  • I have the same problem.  does anyone have any update? This isssue is not consistent either, all my dev and test servers are working without any issues.(all macines are same version, security updates etc etc)

    Sunday, July 12, 2009 10:47 PM
  • An old one - but did you get this resolved? I am wondering if the issues is searching multiple scopes ...

    Ben Weeks
    SharePoint Consultant @ Webtechy Ltd
    T: +441223922070 F: +448701315220
    Web: http://www.webtechy.co.uk Blog: http://blog.webtechy.co.uk

    Saturday, December 8, 2012 1:05 AM