changeset 17:e51c3c807650

Simple Search: Allow leading wildcard
author Fox
date Sun, 10 Apr 2022 03:38:26 +0200
parents 736bcfba1d2d
children 60104bfcffff
files src/junotu/Database.java src/junotu/Main.java
diffstat 2 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/junotu/Database.java	Sun Apr 10 02:32:40 2022 +0200
+++ b/src/junotu/Database.java	Sun Apr 10 03:38:26 2022 +0200
@@ -172,7 +172,7 @@
 
 	luceneWriter.deleteDocuments( query );
 	luceneWriter.addDocument( cardToDocument( card ) );
-	System.out.print("Updated card with identifier "+Long.toString(card.identifierGet())+": '"+card.titleGet()+"'\n");
+	System.out.print( "Updated card with identifier "+Long.toString(card.identifierGet())+": '"+card.titleGet()+"'\n" );
 	searcherRefresh();
 	//luceneWriter.commit();
 	
@@ -240,14 +240,22 @@
 	
 	try {
 	    /* TODO: FIXME: Don't use advanced QueryParser for simple search. */
-	    queryTitle = new QueryParser(
-					 LUCENE_VERSION,
-					 Card.TAG_TITLE,
-					 new StandardAnalyzer(LUCENE_VERSION)).parse(query);
-	    queryContent = new QueryParser(
-					   LUCENE_VERSION,
-					   Card.TAG_CONTENT,
-					   new StandardAnalyzer(LUCENE_VERSION)).parse(query);
+	    QueryParser queryTitleParser = new QueryParser(
+							   LUCENE_VERSION,
+							   Card.TAG_TITLE,
+							   new StandardAnalyzer(LUCENE_VERSION));
+	    QueryParser queryContentParser = new QueryParser(
+							     LUCENE_VERSION,
+							     Card.TAG_CONTENT,
+							     new StandardAnalyzer(LUCENE_VERSION));
+
+	    queryTitleParser.setAllowLeadingWildcard( true );
+	    queryContentParser.setAllowLeadingWildcard( true );
+	    
+	    queryTitle   = queryTitleParser.parse( query );
+	    queryContent = queryContentParser.parse( query );
+
+	    
 	} catch( ParseException e ) {
 	    System.out.print( "Search query parsing exception, returning zero results.\n" );
 	    return new Card[0];
--- a/src/junotu/Main.java	Sun Apr 10 02:32:40 2022 +0200
+++ b/src/junotu/Main.java	Sun Apr 10 03:38:26 2022 +0200
@@ -69,6 +69,7 @@
 	//window = windowGetActive();
 	window.tabSwitch( Tab.EDIT );
 	window.tabEdit.cardCreate();
+	System.out.print( "Opening edit tab for newly created card.\n" );
     }
 
     public static void actionCardEdit( Window window, long identifier )
@@ -78,6 +79,7 @@
 	    Card card = database.cardGetByIdentifier( identifier );
 	    window.tabSwitch( Tab.EDIT );
 	    window.tabEdit.cardEdit( card );
+	    System.out.print( "Opening edit tab to edit '"+card.titleGet()+"'.\n" );
 	} catch( Exception e ) {
 	    throw new RuntimeException(e);
 	}