[Namazu-cvs 759] r247 - Search-Namazu/trunk/Search-Namazu

cvsd @ vaj.namazu.org cvsd @ vaj.namazu.org
2006年 3月 29日 (水) 09:50:45 JST


Author: knok
Date: 2006-03-29 09:50:44 +0900 (Wed, 29 Mar 2006)
New Revision: 247

Modified:
   Search-Namazu/trunk/Search-Namazu/ChangeLog
   Search-Namazu/trunk/Search-Namazu/Namazu.pm
   Search-Namazu/trunk/Search-Namazu/Namazu.xs
Log:
Added default fields "score", "date" and "rank" in ResultXS.


Modified: Search-Namazu/trunk/Search-Namazu/ChangeLog
===================================================================
--- Search-Namazu/trunk/Search-Namazu/ChangeLog	2006-03-29 00:38:41 UTC (rev 246)
+++ Search-Namazu/trunk/Search-Namazu/ChangeLog	2006-03-29 00:50:44 UTC (rev 247)
@@ -1,6 +1,7 @@
 2006-03-29  NOKUBI Takatsugu  <knok @ daionet.gr.jp>
 
 	* Namazu.{xs,pm}: Added "fields" parameter.
+	  Added default fields "score", "date" and "rank" in ResultXS.
 
 2006-03-28  NOKUBI Takatsugu  <knok @ daionet.gr.jp>
 

Modified: Search-Namazu/trunk/Search-Namazu/Namazu.pm
===================================================================
--- Search-Namazu/trunk/Search-Namazu/Namazu.pm	2006-03-29 00:38:41 UTC (rev 246)
+++ Search-Namazu/trunk/Search-Namazu/Namazu.pm	2006-03-29 00:50:44 UTC (rev 247)
@@ -41,7 +41,7 @@
 
   $x = Search::Namazu::Search(index => '/usr/local/namazu/index',
 				query => 'foo',
-				fields => ["uri", "score", "from"]);
+				fields => ["uri", "from"]);
 
   foreach my $rxs (@$x) {
       print ($rxs->get("uri"), $rxs->get("score"), $rxs->get("from"));
@@ -198,7 +198,8 @@
 
 =head3 get
 
-It returns specified value of field.
+It returns specified value of field. "score", "date" and "rank" is
+set by default.
 
 =head1 COPYRIGHT
 

Modified: Search-Namazu/trunk/Search-Namazu/Namazu.xs
===================================================================
--- Search-Namazu/trunk/Search-Namazu/Namazu.xs	2006-03-29 00:38:41 UTC (rev 246)
+++ Search-Namazu/trunk/Search-Namazu/Namazu.xs	2006-03-29 00:50:44 UTC (rev 247)
@@ -55,6 +55,12 @@
 #endif
 
 #define SEARCH_NAMAZU_FIELDS 5
+#define SCORE "score"
+#define SCORE_LEN strlen(SCORE)
+#define DATE "date"
+#define DATE_LEN strlen(DATE)
+#define RANK "rank"
+#define RANK_LEN strlen(RANK)
 
 static int status = 0;
 
@@ -135,6 +141,7 @@
 		if (i < maxget) {
 			HV *hash;
 			SV *ref;
+			SV *score, *date, *rank;
 			int j;
 			char fcont[BUFSIZE];
 
@@ -146,6 +153,12 @@
 				hv_store(hash, fstr[j], fsize[j], 
 					newSVpv(fcont, strlen(fcont)), 0);
 			}
+			score = newSViv(hlist.data[i].score);
+			date = newSViv(hlist.data[i].date);
+			rank = newSViv(hlist.data[i].rank);
+			hv_store(hash, SCORE, SCORE_LEN, score, 0);
+			hv_store(hash, DATE, DATE_LEN, date, 0);
+			hv_store(hash, RANK, RANK_LEN, rank, 0);
 
 			ref = newRV_inc((SV*) hash);
 			sv_bless(ref, stash);




Namazu-cvs メーリングリストの案内