Loading...

All project content is available for reading, but you need to be a member of the project for Subversion checkout of source code, or to create/modify any information.
Login if you are a member. Apply here to request membership (open to all).

Ticket #183 (closed enhancement: fixed)

Opened 8 years ago

Last modified 8 years ago

Custom search and sorting

Reported by: mari@… Owned by: andyturl@…
Priority: minor Component: EasySearch
Keywords: Cc:

Description

I've created a custom search to populate my NewsArchive. The search code basically looks like this:

LuceneQuery queryInterface = (LuceneQuery)EasySearchConfiguration.Instance.QueryInterface;

TermQuery q = new TermQuery(new Term("easysearch_pagetypeid", "6"));

List<Document> docs = queryInterface.Search(q, this.pageSelector.PageSize * pageSelector.PageNumber,
                                                       this.pageSelector.PageSize, out totalResults);

The search works fine, the problem is the sort order of the items returned (oldest items first). Is there anyway to specify a sort order for the query?

PS: The reason why I'm using Search() and not FindPagesWithCriteria() is that I want to make use of the paging control, and only fetch nr of pages specified as pagesize.

Change History

comment:1 Changed 8 years ago by andyturl@…

Hi Mari,

It's possible to use a Sort() object to specify the field(s) to sort on and the direction when doing the search, I will look at adding an overload on the Search() to accept this. I'll let you know when it's checked in.

comment:2 Changed 8 years ago by andyturl@…

  • Status changed from new to closed
  • Resolution set to fixed

LuceneQuery now has an overloaded Search method that accepts a Sort object to sort results by a specific field.

comment:3 Changed 8 years ago by mari@…

Yes, that was what I was looking for. Works like a charm, thanks!

Note: See HelpUser/Tickets for help on using tickets.