Rev 285 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 17-Jun-2010@author: gaurav'''import osimport lucenefrom datastore.DataAccessor import *lucene.initVM(classpath=lucene.CLASSPATH)ps = os.pathsepds = os.sep#analyzer = lucene.analyzer = lucene.StandardAnalyzer()#analyzer = lucene.SimpleAnalyzer()# Creating the Indexpath_index1 = ds+"home"+ds+"gaurav"+ds+"code" + ds + "index1"#Create the Index Writerwriter = lucene.IndexWriter(path_index1,analyzer,True)da = DataHelper()da.initxy()phones = da.get_all_infibeam_data()for p in phones:doc = lucene.Document()id = p.id#print iddoc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))name = p.name#print namedoc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))price = p.final_price#print pricedoc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))writer.addDocument(doc)print str(writer.docCount())writer.close()