Page 1 of 1

How to apply sorting/ordering in a Lucene query in the Query Browser?

Posted: Thu Feb 01, 2018 3:52 pm
by ALMighty
Hello!

I am aware that you could apply sorting/ordering by clicking on the columns
but I am interested if it possible just with using the syntax in the query browser.

The reason why I ask: I had the similiar problem like in the thread "Sorting WI in Matrix view". In the Matrix view, you have no columns for sorting at your disposal but the Query field exists so if sorting with the query field only is possible, that would be cool.

Something like that (you see the attachment also as a screenshot below):

Code: Select all

NOT HAS_VALUE:resolution AND assignee.id:$[user.id] SORT_BY:title


Is that possible? I was looking through the Lucene Query Parser Syntax documentation since it's syntax is the one used in the query browser but the only thing what I found concerning Sorting was in the section "Range Searches" of said documentation and i actually was not a real sorting/ordering what they mention there.

Re: How to apply sorting/ordering in a Lucene query in the Query Browser?

Posted: Thu Mar 22, 2018 5:28 pm
by smarty
Hello ALMighty,

the only ways sorting query results I know of are
- in the context of Polarion's wiki macros like {workitems query= ... sortby=} (cf. help page, search in page for "sortable fields")

- using the Java API like this: $trackerService.queryWorkItems($query, "~id"),
i.e. a tilde symbol to sort descending by WI id.

Regards, Martin

Re: How to apply sorting/ordering in a Lucene query in the Query Browser?

Posted: Tue Mar 27, 2018 10:41 am
by J├╝rgen
In another thread viewtopic.php?t=97701
there is an example that uses SQL for sorting. And it is also possible to use lucene queries in SQL, so it should work to write something like

select * from polarion.WorkItem
where polarion.WorkItem.c_pk in (select * from polarion.lucene_query('WorkItem', 'type:software_design AND project.id:xxxxxx', 'id'))
order by polarion.WorkItem.c_title

Don't know if this works in a table view though.