Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have this querypacket to query Search.asmx service, and get back the results, stored in queryXML object, I can retrieve data successfully, but I can't figure out how to sort this data on any field I need, currently I need to sort data by Modified Date, but I can't even sort it on the Title column.

I tried write <OrderBy><FieldRef Name='Write' Type='Date' Ascending='False'/></OrderBy>

I also tried <SortByProperties> <SortByProperty name='Write' direction='Ascending'/></SortByProperties>

Also didn't work, here is the full querypacket:

"<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'>
            <Query domain='QDomain'>
             <SupportedFormats>
                <Format>urn:Microsoft.Search.Response.Document.Document</Format> 
             </SupportedFormats> 
             <Context> 
               <QueryText language='en-US' type='MSSQLFT' > 
              <![CDATA[ SELECT Title, Path, Description, Rank,  FirstName, LastName , Write, PictureURL FROM scope() 
              WHERE CONTAINS(*,'\"" + query + "*\"') AND \"scope\" = '" + scopetype + "' 
              ]]></QueryText> 
             </Context> 
<OrderBy>
         <FieldRef Name='Title' Type = 'Text' Ascending='False'/>   
                    </OrderBy>
             <Range><StartAt>"+(1+(quickSearchSelectedPageIndex*quickSearchConfig.numberOfResults))+"</StartAt> 
             <Count>" + quickSearchConfig.numberOfResults + "</Count></Range> 
             <EnableStemming>false</EnableStemming> 
             <TrimDuplicates>true</TrimDuplicates>  
             <IgnoreAllNoiseQuery>true</IgnoreAllNoiseQuery> 
             <ImplicitAndBehavior>true</ImplicitAndBehavior> 
             <IncludeRelevanceResults>true</IncludeRelevanceResults> 
             <IncludeSpecialTermResults>true</IncludeSpecialTermResults> 
             <IncludeHighConfidenceResults>true</IncludeHighConfidenceResults> 
            </Query></QueryPacket>";  

Note that scopetype is a variable indicating the scope, and the query is the string of my real query.

share|improve this question
    
So you just get not sorted data in response, or is there some error? –  Andrey Markeev Aug 24 '13 at 21:25
    
No error at all, but the latest document doesn't appear to be the first one, I have them in Ascending Order depending on the date, and can't get them to be in Descending Order, I tried several methods for the ordering as described, but didn't work, but no errors at all. Any suggestions? –  Mohamed Derhalli Aug 24 '13 at 21:49
1  
Have you checked that the managed properties are configured as Sortable? –  Andrey Markeev Aug 25 '13 at 0:36
    
Where do I check that from? –  Mohamed Derhalli Aug 25 '13 at 1:03
    
That depends on the version of SharePoint you're using. For SP2013 it would be smth like Central administration -> Search Service Application => Search Schema => Managed Properties => Edit property => Sortable => set to Yes. For SP2010, Central Administration => Search Service Application => Managed Properties => tick ON the checkbox "Reduce storage requirements for text properties by using a hash for comparison" –  Andrey Markeev Aug 25 '13 at 11:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.