Searching multiple scopes with All Content and an exclude rule returns "The search query is malformed"Hi, <p>I have two scopes which are being used in an Advanced Search Box web part. The two scopes contain the following rules:</p> <p>Scope1: <br>    rule: All Content<br>    behavior: Include</p> <p>Scope2:<br>    rule: ContentSource = MyContentSource<br>    behavior: Include<br>    <br>In the Advanced Search Box web part for the option &quot;Only the scope(s)&quot; I am able to check both scopes and perform a successful search*.</p> <p>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 &quot;Your search cannot be completed because of a service error. Try your search again or contact your administrator for more information&quot;</p> <p>The SharePoint logs contains: &quot;Microsoft.Office.Server.Search.Query.QueryMalformedException: Your query is malformed. Please rephrase your query&quot; thrown from Microsoft.Office.Server.Search.Query.FullTextSqlQuery.Execute.</p> <p>I tested with the web service /_vti_bin/search.asmx and executed the following search query:<br><br></p> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:blue">using</font><font style="font-size:11px"> (search.QueryService qs = </font><font style="color:blue">new</font><font style="font-size:11px"> WebService.search.QueryService())  </font></td></tr> <tr> <td style="background-color:#f7f7f7">{  </td></tr> <tr> <td>    qs.Credentials = System.Net.CredentialCache.DefaultCredentials;  </td></tr> <tr> <td style="background-color:#f7f7f7">    StringBuilder query = </font><font style="color:blue">new</font><font style="font-size:11px"> StringBuilder();  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;?xml version=\&quot;</font><font style="font-size:11px">1.0\</font><font style="color:blue">&quot; encoding=\&quot;</font><font style="font-size:11px">utf-8\</font><font style="color:blue">&quot; ?&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;QueryPacket xmlns=\&quot;</font><font style="font-size:11px">urn:Microsoft.Search.Query\</font><font style="color:blue">&quot; Revision=\&quot;</font><font style="font-size:11px">1000\</font><font style="color:blue">&quot;&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;Query domain=\&quot;</font><font style="font-size:11px">QDomain\</font><font style="color:blue">&quot;&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;SupportedFormats&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;Format&gt;urn:Microsoft.Search.Response.Document.Document&lt;/Format&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;/SupportedFormats&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;Context&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;QueryText language=\&quot;</font><font style="font-size:11px">en-US\</font><font style="color:blue">&quot; type=\&quot;</font><font style="font-size:11px">MSSQLFT\</font><font style="color:blue">&quot;&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;SELECT &quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;Title, Path, Description, Write, Rank, Size &quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;FROM SCOPE() &quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;WHERE &quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;((\&quot;</font><font style="font-size:11px">Scope\</font><font style="color:blue">&quot;='Scope1') OR (\&quot;</font><font style="font-size:11px">Scope\</font><font style="color:blue">&quot;='Scope2')) &quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;AND FREETEXT(DEFAULTPROPERTIES,'jpg')&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;/QueryText&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;/Context&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;/Query&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;/QueryPacket&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    </font><font style="color:blue">string</font><font style="font-size:11px"> results = qs.Query(query.ToString());  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">using</font><font style="font-size:11px"> (System.IO.StreamWriter file = </font><font style="color:blue">new</font><font style="font-size:11px"> System.IO.StreamWriter(</font><font style="color:blue">&quot;SearchResults.xml&quot;</font><font style="font-size:11px">))  </font></td></tr> <tr> <td>    {  </td></tr> <tr> <td style="background-color:#f7f7f7">        file.Write(results);  </td></tr> <tr> <td>    }                          </td></tr> <tr> <td style="background-color:#f7f7f7">} </td></tr></tbody></table></div><br>And got the same results:<br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:blue">&lt;</font><font style="font-size:11px">ResponsePacket</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">&lt;</font><font style="font-size:11px">Response </font><font style="color:red">domain</font><font style="font-size:11px">=</font><font style="color:blue">&quot;QDomain&quot;</font><font style="font-size:11px">&gt;  </font></td></tr> <tr> <td></font><font style="color:blue">&lt;</font><font style="font-size:11px">Status</font><font style="color:blue">&gt;</font><font style="font-size:11px">ERROR_BAD_QUERY</font><font style="color:blue">&lt;/</font><font style="font-size:11px">Status</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">&lt;</font><font style="font-size:11px">DebugErrorMessage</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>Your query is malformed. Please rephrase your query.  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">&lt;/</font><font style="font-size:11px">DebugErrorMessage</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:blue">&lt;/</font><font style="font-size:11px">Response</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">&lt;/</font><font style="font-size:11px">ResponsePacket</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr></tbody></table></div><br> <p>The condition that triggers the failed search is when a scope contains the &quot;All Content&quot; 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 &quot;All Content&quot; rule will not trigger this problem.</p> <p>Is a scope with the rules including All Content and then excluding specific content sources supported?<br></p> <p>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 &quot;All Content&quot; rule.<br><br>I'm running MOSS 20007 version 12.0.0.6219.<br><br>Thanks<br>Matt<br><br>* 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.<br></p>© 2009 Microsoft Corporation. All rights reserved.Sun, 12 Jul 2009 22:47:59 Zfb78decc-aeb5-4c04-bb75-473c25f8c11dhttp://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/fb78decc-aeb5-4c04-bb75-473c25f8c11d#fb78decc-aeb5-4c04-bb75-473c25f8c11dhttp://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/fb78decc-aeb5-4c04-bb75-473c25f8c11d#fb78decc-aeb5-4c04-bb75-473c25f8c11dmr2008http://social.technet.microsoft.com/Profile/en-US/?user=mr2008Searching multiple scopes with All Content and an exclude rule returns "The search query is malformed"Hi, <p>I have two scopes which are being used in an Advanced Search Box web part. The two scopes contain the following rules:</p> <p>Scope1: <br>    rule: All Content<br>    behavior: Include</p> <p>Scope2:<br>    rule: ContentSource = MyContentSource<br>    behavior: Include<br>    <br>In the Advanced Search Box web part for the option &quot;Only the scope(s)&quot; I am able to check both scopes and perform a successful search*.</p> <p>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 &quot;Your search cannot be completed because of a service error. Try your search again or contact your administrator for more information&quot;</p> <p>The SharePoint logs contains: &quot;Microsoft.Office.Server.Search.Query.QueryMalformedException: Your query is malformed. Please rephrase your query&quot; thrown from Microsoft.Office.Server.Search.Query.FullTextSqlQuery.Execute.</p> <p>I tested with the web service /_vti_bin/search.asmx and executed the following search query:<br><br></p> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:blue">using</font><font style="font-size:11px"> (search.QueryService qs = </font><font style="color:blue">new</font><font style="font-size:11px"> WebService.search.QueryService())  </font></td></tr> <tr> <td style="background-color:#f7f7f7">{  </td></tr> <tr> <td>    qs.Credentials = System.Net.CredentialCache.DefaultCredentials;  </td></tr> <tr> <td style="background-color:#f7f7f7">    StringBuilder query = </font><font style="color:blue">new</font><font style="font-size:11px"> StringBuilder();  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;?xml version=\&quot;</font><font style="font-size:11px">1.0\</font><font style="color:blue">&quot; encoding=\&quot;</font><font style="font-size:11px">utf-8\</font><font style="color:blue">&quot; ?&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;QueryPacket xmlns=\&quot;</font><font style="font-size:11px">urn:Microsoft.Search.Query\</font><font style="color:blue">&quot; Revision=\&quot;</font><font style="font-size:11px">1000\</font><font style="color:blue">&quot;&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;Query domain=\&quot;</font><font style="font-size:11px">QDomain\</font><font style="color:blue">&quot;&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;SupportedFormats&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;Format&gt;urn:Microsoft.Search.Response.Document.Document&lt;/Format&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;/SupportedFormats&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;Context&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;QueryText language=\&quot;</font><font style="font-size:11px">en-US\</font><font style="color:blue">&quot; type=\&quot;</font><font style="font-size:11px">MSSQLFT\</font><font style="color:blue">&quot;&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;SELECT &quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;Title, Path, Description, Write, Rank, Size &quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;FROM SCOPE() &quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;WHERE &quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;((\&quot;</font><font style="font-size:11px">Scope\</font><font style="color:blue">&quot;='Scope1') OR (\&quot;</font><font style="font-size:11px">Scope\</font><font style="color:blue">&quot;='Scope2')) &quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;AND FREETEXT(DEFAULTPROPERTIES,'jpg')&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;/QueryText&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;/Context&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    query.Append(</font><font style="color:blue">&quot;&lt;/Query&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    query.Append(</font><font style="color:blue">&quot;&lt;/QueryPacket&gt;&quot;</font><font style="font-size:11px">);  </font></td></tr> <tr> <td>    </font><font style="color:blue">string</font><font style="font-size:11px"> results = qs.Query(query.ToString());  </font></td></tr> <tr> <td style="background-color:#f7f7f7">    </font><font style="color:blue">using</font><font style="font-size:11px"> (System.IO.StreamWriter file = </font><font style="color:blue">new</font><font style="font-size:11px"> System.IO.StreamWriter(</font><font style="color:blue">&quot;SearchResults.xml&quot;</font><font style="font-size:11px">))  </font></td></tr> <tr> <td>    {  </td></tr> <tr> <td style="background-color:#f7f7f7">        file.Write(results);  </td></tr> <tr> <td>    }                          </td></tr> <tr> <td style="background-color:#f7f7f7">} </td></tr></tbody></table></div><br>And got the same results:<br><br> <div style="border-right:#7f9db9 1px solid;border-top:#7f9db9 1px solid;font-size:11px;overflow:auto;border-left:#7f9db9 1px solid;line-height:100%! important;border-bottom:#7f9db9 1px solid;font-family:Courier New;background-color:white"> <table style="border-top-width:0px;border-left-width:0px;margin:2px 0px;width:99%;border-bottom:#eee 0px solid;border-collapse:collapse;background-color:#fff;border-right-width:0px" cellspacing=0 cellpadding=0> <colgroup> <col style="padding-left:10px;font-size:11px;border-bottom:#f7f7f7 1px solid;font-family:Courier New;white-space:nowrap"> <tbody> <tr> <td><font style="font-size:11px"></font><font style="color:blue">&lt;</font><font style="font-size:11px">ResponsePacket</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">&lt;</font><font style="font-size:11px">Response </font><font style="color:red">domain</font><font style="font-size:11px">=</font><font style="color:blue">&quot;QDomain&quot;</font><font style="font-size:11px">&gt;  </font></td></tr> <tr> <td></font><font style="color:blue">&lt;</font><font style="font-size:11px">Status</font><font style="color:blue">&gt;</font><font style="font-size:11px">ERROR_BAD_QUERY</font><font style="color:blue">&lt;/</font><font style="font-size:11px">Status</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">&lt;</font><font style="font-size:11px">DebugErrorMessage</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td>Your query is malformed. Please rephrase your query.  </td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">&lt;/</font><font style="font-size:11px">DebugErrorMessage</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td></font><font style="color:blue">&lt;/</font><font style="font-size:11px">Response</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr> <tr> <td style="background-color:#f7f7f7"></font><font style="color:blue">&lt;/</font><font style="font-size:11px">ResponsePacket</font><font style="color:blue">&gt;</font><font style="font-size:11px"> </font></td></tr></tbody></table></div><br> <p>The condition that triggers the failed search is when a scope contains the &quot;All Content&quot; 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 &quot;All Content&quot; rule will not trigger this problem.</p> <p>Is a scope with the rules including All Content and then excluding specific content sources supported?<br></p> <p>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 &quot;All Content&quot; rule.<br><br>I'm running MOSS 20007 version 12.0.0.6219.<br><br>Thanks<br>Matt<br><br>* 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.<br></p>Tue, 02 Sep 2008 11:39:54 Z2008-09-02T11:39:54Zhttp://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/fb78decc-aeb5-4c04-bb75-473c25f8c11d#d61fc1b7-c86c-41e6-8174-e57a878c37f8http://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/fb78decc-aeb5-4c04-bb75-473c25f8c11d#d61fc1b7-c86c-41e6-8174-e57a878c37f8Poochi74http://social.technet.microsoft.com/Profile/en-US/?user=Poochi74Searching multiple scopes with All Content and an exclude rule returns "The search query is malformed"Hi,<br><br>  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? <br><br>I would appreciate any help...<br><br>Thanks,<br> Wed, 14 Jan 2009 19:31:48 Z2009-01-14T19:31:48Zhttp://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/fb78decc-aeb5-4c04-bb75-473c25f8c11d#79f6b328-c0c8-4a59-b6f8-2bf7370e3010http://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/fb78decc-aeb5-4c04-bb75-473c25f8c11d#79f6b328-c0c8-4a59-b6f8-2bf7370e3010Parthttp://social.technet.microsoft.com/Profile/en-US/?user=PartSearching multiple scopes with All Content and an exclude rule returns "The search query is malformed"<p>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)</p>Sun, 12 Jul 2009 22:47:58 Z2009-07-12T22:47:58Z