Subversion Repositories SmartDukaan

Rev

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 os
import lucene
from datastore.DataAccessor import *

lucene.initVM(classpath=lucene.CLASSPATH)
ps = os.pathsep
ds = os.sep
 
#analyzer = lucene.
analyzer = lucene.StandardAnalyzer()
#analyzer = lucene.SimpleAnalyzer()
# Creating the Index
path_index1 = ds+"home"+ds+"gaurav"+ds+"code" + ds + "index1"
#Create the Index Writer
writer = 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 id
    doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
    name = p.name
    #print name
    doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
    price = p.final_price 
    #print price
    doc.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()