none
Sharepoint Search - Sorting - SearchResultsHiddenObjects RRS feed

  • Question

  • We created a custom webpart for search results by inheriting CoreResultWebpart. We dynamically created the FullTextQuery based on our requirement, and its assign to the FullTextQuery property in SearchResultsHiddenObject type.Its worked fine.
    The problem here is, we are not able to use the sorting i.e "OrderBy" in the FullTextQuery. while executing the query it shows the query is malformed. It occurs only in the case of SearchResultsHiddenObjects type.

    The same query which is executed correctly and i able to bind into the resultsset. but its not work in the SearchResultsHiddenObjects type.

    Please help me to resolve this issue

    -Kathir
    Wednesday, February 11, 2009 10:22 AM

Answers

  • Hello Kathir,

    I had the same problem and the fix is simple: just add a SQL comment ( -- ) at the end of the ORDER BY

    Example:

    SELECT WorkId, Rank, Title, Author, Size, Path, Description, Write, SiteName, CollapsingStatus, HitHighlightedSummary, HitHighlightedProperties, ContentClass, IsDocument, PictureThumbnailURL FROM Scope() WHERE "scope"='Your Scope' AND Title LIKE 'dorp%' ORDER BY Title, Author --

    The ' --' does the trick because everyting that the CoreResultsWebpart adds after this wil be ignored :-)

    Regards,

    Theo
    Tuesday, May 19, 2009 9:20 AM

All replies

  • What version of MOSS 2007 are you running, any service packs or hotfixes applied?  We had a similar problem with an earlier release of MOSS 2007, but it no longer occurs using the October cumulative update.
    Thursday, February 26, 2009 4:38 AM
  • I have experienced this myself since I have written a web part to do that very thing.  The issue is the builtin functionality for the choices of searching by Relevance or Date append an ORDER BY clause to whatever you specify as your FullTextSqlQuery.  I think you can get around this, but it would take some work with reflector to find out where it is getting set and override this functionality so that you can use your own order by clause.

    Thanks,
    Corey
    Thursday, February 26, 2009 2:50 PM
  • Hello Kathir,

    I had the same problem and the fix is simple: just add a SQL comment ( -- ) at the end of the ORDER BY

    Example:

    SELECT WorkId, Rank, Title, Author, Size, Path, Description, Write, SiteName, CollapsingStatus, HitHighlightedSummary, HitHighlightedProperties, ContentClass, IsDocument, PictureThumbnailURL FROM Scope() WHERE "scope"='Your Scope' AND Title LIKE 'dorp%' ORDER BY Title, Author --

    The ' --' does the trick because everyting that the CoreResultsWebpart adds after this wil be ignored :-)

    Regards,

    Theo
    Tuesday, May 19, 2009 9:20 AM
  • I went ahead and added this functioinality to the Wildcard Search web part on Codeplex.  There is a new SortOrder property that you can specify on it to provide this functionality.

    http://wildcardsearch.codeplex.com/

    Thanks,
    Corey
    Corey Roth blog: www.dotnetmafia.com twitter: twitter.com/coreyroth
    Thursday, May 21, 2009 2:04 PM
  • Hi Corey,

    I am trying to do something veery similar - add property for content Publication date and secondly add a claues that would manage search scopes.

    I create search scopes with rules in Central Administration so all i want is to add

    to the WHERE clause .. 

    AND ( (scope='scopeName1' OR scope=' scopeName2 ' ) AND scope=' scopeName3 ' AND content.publicationdate < 1January )

    unfortunatelly i cant get it to work, how should it be?

    As for the publication date - does all content has it? Fo example if i add a element to some list .. the query also should take it into consideration..

    my scopes are configured with rules in Central Administration. They are standard rules containing site addresses, list addreses etc

    Saturday, March 20, 2010 4:00 PM