TechNet - Только для профессионалов. Специально для Вас. > Форумы > SharePoint - Search > Searching multiple scopes with All Content and an exclude rule returns "The search query is malformed"
Задайте вопросЗадайте вопрос
 

ВопросSearching multiple scopes with All Content and an exclude rule returns "The search query is malformed"

  • 2 сентября 2008 г. 11:39mr2008 Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     С кодом
    Hi,

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

    Scope1:
        rule: All Content
        behavior: Include

    Scope2:
        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("<SupportedFormats>");  
        query.Append("<Format>urn:Microsoft.Search.Response.Document.Document</Format>");  
        query.Append("</SupportedFormats>");  
        query.Append("<Context>");  
        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')");  
        query.Append("</QueryText>");  
        query.Append("</Context>");  
        query.Append("</Query>");  
        query.Append("</QueryPacket>");  
        string results = qs.Query(query.ToString());  
        using (System.IO.StreamWriter file = new System.IO.StreamWriter("SearchResults.xml"))  
        {  
            file.Write(results);  
        }                          

    And got the same results:

    <ResponsePacket> 
    <Response domain="QDomain">  
    <Status>ERROR_BAD_QUERY</Status> 
    <DebugErrorMessage> 
    Your query is malformed. Please rephrase your query.  
    </DebugErrorMessage> 
    </Response> 
    </ResponsePacket> 

    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 12.0.0.6219.

    Thanks
    Matt

    * 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.

Все ответы