Skip to main content.
home | support | download

Back to List Archive

Re: Sorting issues

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Wed Jan 02 2002 - 18:43:48 GMT
At 09:52 AM 01/02/02 -0800, Zambra - Michael wrote:
>The problem is that each first level subdirectory has subdirectories below
>and swish proceeds to order all the files  contained in the first level
>directory first and then applies the rank order. Something like that
>
>Section 1 Header
>  Results in subdirectory sectionname_a/a/
>    Results ordered by rank
>  Results in subdirectory sectionname_a/a/
>    Results ordered by rank
>
>I would like to have all the results in subdirectory "sectionname_a" and its
>subdirectories ordered by rank.

Ah, this just came up not too long ago.  It's not a huge issue since you can extract out the path in your front-end (CGI?) script (and sort there), but to let swish do it will require a patch.

There's the ExtractPath directive that lets you extract out part of the path and use that for indexing.  But nothing to extract part of the path and use that as a property.

It would not be that hard to add it, but it will be a day or so before I could get to it.  Oh, wait....

tap tap tap.

Ok, it's now in CVS, or you can apply this path.

ExtractPath foo regex /^(....).+$/$1/
PropertyNames foo

That will extract out the first five chars of the path name, and *both* store it as a metaname "foo", and as a property "foo".

I'm not thrilled because you can't really do one without the other.  But, if that needed one can always use -S prog (and perhaps the DirTree.pl program) and dream up any metaname/properties usage.

I didn't test much, so please report back!

Index: index.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/index.c,v
retrieving revision 1.172
retrieving revision 1.173
diff -u -r1.172 -r1.173
--- index.c	2001/12/30 15:43:17	1.172
+++ index.c	2002/01/02 18:29:40	1.173
@@ -136,7 +136,7 @@
 #include "dump.h"
 #include "swish_qsort.h"
 
-static void index_path_parts( SWISH *sw, char *path, path_extract_list *list );
+static void index_path_parts( SWISH *sw, char *path, path_extract_list *list, INDEXDATAHEADER *header, docProperties **properties );
 
 
 
@@ -1162,7 +1162,7 @@
 
     /* This allows extracting out parts of a path and indexing as a separate meta name */
     if ( sw->pathExtractList )
-        index_path_parts( sw, fprop->orig_path, sw->pathExtractList );
+        index_path_parts( sw, fprop->orig_path, sw->pathExtractList, header, properties );
         
 
 
@@ -1235,7 +1235,7 @@
 *   extracts out parts from a path name and indexes that part
 *
 ********************************************************************/
-static void index_path_parts( SWISH *sw, char *path, path_extract_list *list )
+static void index_path_parts( SWISH *sw, char *path, path_extract_list *list, INDEXDATAHEADER *header, docProperties **properties )
 {
     int metaID;
     int positionMeta = 1;
@@ -1256,8 +1256,15 @@
         }
         else
         {
+            struct metaEntry *q;
+
             metaID = list->meta_entry->metaID;
             indexstring(sw, str, sw->Index->filenum, IN_FILE, 1, &metaID, &positionMeta);
+
+            if ((q = getPropNameByName(header, list->meta_entry->metaName )))
+                addDocProperty( properties, q, str, strlen(str),0);
+            
+
             efree( str );
         }
 

-- 
Bill Moseley
mailto:moseley@hank.org
Received on Wed Jan 2 18:45:17 2002