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

Description
ALMighty
Posts: 80
Joined: Wed Apr 27, 2016 10:34 am
Location: Austria

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

Postby ALMighty » Thu Feb 01, 2018 3:52 pm

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.
Attachments
Query_browser_Lucene_example_with_attempted_sorting.png
Lucene query browser example with attempted sorting/ordering
Query_browser_Lucene_example_with_attempted_sorting.png (11.73 KiB) Viewed 1345 times
---------------------------------------------------------------------------------------------------
Playing a good game is never lame. :D
Image

smarty
Posts: 50
Joined: Fri Jan 18, 2013 4:43 pm
Location: Germany / Frankfurt
Contact:

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

Postby smarty » Thu Mar 22, 2018 5:28 pm

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
My environment: Polarion ALM 2016 SR2 on Windows Server 2012,
Polarion-JIRA Connector to JIRA 7.x

Jürgen
Posts: 43
Joined: Tue Sep 12, 2017 1:02 pm

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

Postby Jürgen » Tue Mar 27, 2018 10:41 am

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.


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 6 guests