Mercurial Hosting > junotu
changeset 113:5c74293fb41a
Cards are now secondarily sorted by modification timestamp when searching
author | Fox |
---|---|
date | Tue, 29 Aug 2023 20:51:51 +0200 |
parents | 9bf9fd26bb33 |
children | 14506c250461 |
files | src/junotu/Database.java |
diffstat | 1 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
diff -r 9bf9fd26bb33 -r 5c74293fb41a src/junotu/Database.java --- a/src/junotu/Database.java Thu Jun 15 03:49:56 2023 +0200 +++ b/src/junotu/Database.java Tue Aug 29 20:51:51 2023 +0200 @@ -467,26 +467,35 @@ System.out.print( "Search query parsing exception, returning zero results: "+e.getMessage()+"\n" ); return new Card[0]; } - + finalQuery = new BooleanQuery(); - + finalQuery.add( parsedQuery, BooleanClause.Occur.SHOULD ); for( int i = 0; i < hideQueries.length; i++ ) { finalQuery.add( hideQueries[i], BooleanClause.Occur.MUST_NOT ); } - + try { - - TopDocs hits = luceneSearcher.search( finalQuery, 32 ); + + TopDocs hits = luceneSearcher.search( + finalQuery, + null, + 32, + new Sort( + SortField.FIELD_SCORE, + new SortField( Card.TAG_LAST_EDIT, SortField.LONG, true ), + new SortField( Card.TAG_SAVED, SortField.LONG, true ) + ) + ); Card[] cards = new Card[hits.scoreDocs.length]; - + for( int i = 0; i < hits.scoreDocs.length; i++ ) { Document document = luceneSearcher.doc( hits.scoreDocs[i].doc ); cards[i] = cardFromDocument( document ); } - + return cards; - + } catch( IOException e ) { throw new RuntimeException(e); }