changed to use new modular SearchTerm classes
authorjohn <john>
Tue, 26 Nov 2002 21:38:11 +0000 (21:38 +0000)
committerjohn <john>
Tue, 26 Nov 2002 21:38:11 +0000 (21:38 +0000)
... looks more like java, less like bad perl

source/mircoders/producer/IndexingProducerNode.java

index 26749dd..4f6d124 100755 (executable)
@@ -53,6 +53,7 @@ import mir.entity.*;
 import mir.entity.adapter.*;
 import mircoders.entity.*;
 import mircoders.storage.*;
+import mircoders.search.*;
 
 
 public class IndexingProducerNode implements ProducerNode {
@@ -100,55 +101,44 @@ public class IndexingProducerNode implements ProducerNode {
       // Text is tokenized,stored, indexed
       // Unindexed is not tokenized or indexed, only stored
       // Unstored is tokenized and indexed, but not stored
+      
+      //this initialization should go somewhere global like an xml file....
 
-      theDoc.add(Field.Keyword("id",entity.getValue("id")));
-      theDoc.add(Field.Keyword("where",entity.getValue("publish_path")+entity.getValue("id")+".shtml"));
-      theDoc.add(Field.Text("creator",entity.getValue("creator")));
-      theDoc.add(Field.Text("title",entity.getValue("title")));
-      theDoc.add(Field.Keyword("webdb_create",entity.getValue("webdb_create_formatted")));
-      theDoc.add(Field.UnStored("content_and_description",entity.getValue("description")+entity.getValue("content_data")));
-
-      //topics
-      TemplateModel topics=entity.get("to_topics");
-      aLogger.debug("THE CLASS NAME WAS: "+entity.get("to_topics").getClass().getName());
-      while (((TemplateListModel)topics).hasNext()){
-        theDoc.add(Field.UnStored("topic",((TemplateHashModel)((TemplateListModel)topics).next()).get("title").toString()));
-      }
 
+      (new KeywordSearchTerm("id","","id","","id")).index(theDoc,entity);
+      (new KeywordSearchTerm("webdb_create_formatted","search_date","webdb_create_formatted","","webdb_create_formatted")).index(theDoc,entity);
 
-      //media
+      (new UnIndexedSearchTerm("","","","where","where")).indexValue(theDoc,entity.getValue("publish_path")+entity.getValue("id")+".shtml");
 
-      //images
-      TemplateModel images=entity.get("to_media_images");
-      if (images != null){
-          //here we should really store a list of urls instead,
-          //so we can thumbnail from another server
-          theDoc.add(Field.UnStored("media","images"));
+      (new TextSearchTerm("creator","search_creator","creator","","creator")).index(theDoc,entity);
+      (new TextSearchTerm("title","search_title","title","","title")).index(theDoc,entity);
+      (new TextSearchTerm("description","search_content","description","","description")).index(theDoc,entity);
+
+      (new UnStoredSearchTerm("content_data","search_content","content","","")).index(theDoc,entity);
+
+      (new TopicSearchTerm()).index(theDoc,entity);
+
+      (new ImagesSearchTerm()).index(theDoc,entity);
+      
+      (new AudioSearchTerm()).index(theDoc,entity);
+      
+      (new VideoSearchTerm()).index(theDoc,entity);
 
-      }
-      //audio
-      TemplateModel audio=entity.get("to_media_audio");
-      if (audio != null){
-        theDoc.add(Field.UnStored("media","audio"));
-      }
-      //video
-      TemplateModel video=entity.get("to_media_video");
-      if (video != null){
-        theDoc.add(Field.UnStored("media","video"));
-      }
 
       //comments-just aggregate all relevant fields
-      String commentsAggregate = "";
-      TemplateModel comments=entity.get("to_comments");
-      if (comments != null){
-        while (((TemplateListModel)comments).hasNext()){
-          TemplateModel aComment = ((TemplateListModel)comments).next();
-          commentsAggregate = commentsAggregate + " " + ((TemplateHashModel)aComment).get("title").toString()
-            + " " + ((TemplateHashModel)aComment).get("creator").toString()
-            + " " + ((TemplateHashModel)aComment).get("text").toString();
-        }
-      }
-      theDoc.add(Field.UnStored("comments",commentsAggregate));
+      //removed until i get a chance to do this right
+
+      //String commentsAggregate = "";
+      //TemplateModel comments=entity.get("to_comments");
+      //if (comments != null){
+      // while (((TemplateListModel)comments).hasNext()){
+      //    TemplateModel aComment = ((TemplateListModel)comments).next();
+      //    commentsAggregate = commentsAggregate + " " + ((TemplateHashModel)aComment).get("title").toString()
+      //     + " " + ((TemplateHashModel)aComment).get("creator").toString()
+      //      + " " + ((TemplateHashModel)aComment).get("text").toString();
+      //  }
+      //}
+      //theDoc.add(Field.UnStored("comments",commentsAggregate));
 
       indexWriter.addDocument(theDoc);