fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2012-01-19 07:48 am

[dw-free] Highlight in subjects as well as content when searching

[commit: http://hg.dwscoalition.org/dw-free/rev/53b7f7d82aa3]

http://bugs.dwscoalition.org/show_bug.cgi?id=1847

Add subject highlighting in searches.

Patch by [personal profile] the_wanlorn.

Files modified:
  • bin/worker/sphinx-search-gm
--------------------------------------------------------------------------------
diff -r 5aa38d807317 -r 53b7f7d82aa3 bin/worker/sphinx-search-gm
--- a/bin/worker/sphinx-search-gm	Tue Jan 17 08:29:51 2012 +0000
+++ b/bin/worker/sphinx-search-gm	Thu Jan 19 15:46:33 2012 +0800
@@ -124,6 +124,7 @@
         # try to figure out the language of the journal being searched (or the searcher?) and use
         # an appropriate stemming library?  (future expansion opportunity)
         my $exc = $sx->BuildExcerpts( [ map { $_->{entry} } @out ], 'dw1stemmed', $query, {} ) || [];
+        my $subj = $sx->BuildExcerpts( [ map { $_->{subject} } @out ], 'dw1stemmed', $query, {} ) || [];
 
         # if we have a matching number of excerpts to events, then we can determine
         # which one goes with which post.
@@ -131,6 +132,7 @@
             foreach my $m ( @out ) {
                 delete $m->{entry};
                 $m->{excerpt} = shift @$exc;
+                $m->{subject} = shift @$subj;
             }
 
         } else {
--------------------------------------------------------------------------------