Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Creating a Custom Sort

Lionel Hutz
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 1, 2011

The instructions on this page give a good overview of how to create a new search query, but I was wondering if I could get some instructions on how to create a new SearchSort.

http://confluence.atlassian.com/display/CONFDEV/Extending+the+V2+search+API

I created the sort but need come kind of mapper that implements the sort. My query works just fine when used with the PredefinedSearchBuilder, but when I try to add the sort to SearchQueryParameters, I get this in the logs:

"A lucene mapper could not be found to map the specified search"

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Lionel Hutz
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 4, 2011

Ok I figured out what to do. Basically I just needed to write my own extractor that adds the fields un-tokenized to the index and then have my sort reference the un-tokenized fields. This is exactly what the page title does and now I can make Lucene do all the work of searching and sorting.

Basically "handles" maps your SearchSort the the appropriate mapper(I just used the case insensitive one) while sortfield allows you to specify a different field to actually sort on (the un-tokenized one in my case).

The discussion here helped:

https://jira.atlassian.com/browse/CONF-5322

0 votes
Lionel Hutz
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 2, 2011

Ok one more tidbit. I think part of the issue is the metadata is tokenized. Simple metadata (such as AAA, BBB, CCC, DDD, etc) seem to sort correctly but throwing spaces and special characters into the mix breaks the sort for those items.

According to this page:

http://confluence.atlassian.com/display/DOC/Confluence+Search+Fields

the page title is also tokenized, but it can be sorted anyway. How can I apply this to metadata?

0 votes
Lionel Hutz
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 1, 2011

Ok I was able to find LuceneSortMapper burried here:

http://confluence.atlassian.com/display/CONFDEV/Confluence+Plugin+Module+Types

and lucene-sort-mapper (which takes an additional "sortField" param) in a random svn commit that was picked up by google, but this doesn't seem to work for metadata (specifically scaffolding fields). Is it not possible to sort this way?

TAGS
AUG Leaders

Atlassian Community Events