Subversion Repositories SmartDukaan

Rev

Rev 278 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
278 ashish 1
'''
2
Created on 17-Jun-2010
3
 
4
@author: gaurav
5
'''
6
 
7
import os
8
import lucene
9
from datastore.DataAccessor import *
10
 
11
lucene.initVM(classpath=lucene.CLASSPATH)
12
ps = os.pathsep
13
ds = os.sep
285 ashish 14
da = DataHelper()
15
da.initxy()
278 ashish 16
 
17
analyzer = lucene.StandardAnalyzer()
18
# Creating the Index
285 ashish 19
path_index1 = ds+"home"+ds+"gaurav"+ds+"code" + ds + "infibeamindex"
278 ashish 20
#Create the Index Writer
21
writer = lucene.IndexWriter(path_index1,analyzer,True) 
22
 
23
 
24
phones = da.get_all_infibeam_data()
25
for p in phones:
26
    doc = lucene.Document()
27
    id = p.id
28
    doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
29
    name = p.name
30
    doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
31
    price = p.final_price 
32
    doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
285 ashish 33
    #print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
278 ashish 34
    writer.addDocument(doc)
285 ashish 35
    #print str(writer.docCount())
36
writer.close()
278 ashish 37
 
285 ashish 38
path_index2 = ds+"home"+ds+"gaurav"+ds+"code" + ds + "indiaplazaindex"
39
#Create the Index Writer
40
writer = lucene.IndexWriter(path_index2,analyzer,True) 
278 ashish 41
 
285 ashish 42
phones = da.get_all_indiaplaza_phones()
43
for p in phones:
44
    doc = lucene.Document()
45
    id = p.id
46
    doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
47
    name = p.p_name
48
    doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
49
    price = p.p_final_price 
50
    doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
51
    #print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
52
    writer.addDocument(doc)
53
    #print str(writer.docCount())
54
writer.close()  
55
 
56
 
57
path_index3 = ds+"home"+ds+"gaurav"+ds+"code" + ds + "univercellindex"
58
#Create the Index Writer
59
writer = lucene.IndexWriter(path_index3,analyzer,True) 
60
 
61
phones = da.get_all_univercell_phones()
62
for p in phones:
63
    doc = lucene.Document()
64
    id = p.id
65
    doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
66
    name = p.p_title
67
    doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
68
    price = p.p_final_price 
69
    doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
70
    #print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
71
    writer.addDocument(doc)
72
    #print str(writer.docCount())
73
writer.close()    
74
 
75
 
76
path_index4 = ds+"home"+ds+"gaurav"+ds+"code" + ds + "babuchakindex"
77
#Create the Index Writer
78
writer = lucene.IndexWriter(path_index4,analyzer,True) 
79
 
80
phones = da.get_allbabuchakphones()
81
for p in phones:
82
    doc = lucene.Document()
83
    id = p.id
84
    doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
85
    name = p.name
86
    doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
87
    price = p.final_price 
88
    doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
89
    #print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
90
    writer.addDocument(doc)
91
    #print str(writer.docCount())
92
writer.close()    
93
 
94
path_index5 = ds+"home"+ds+"gaurav"+ds+"code" + ds + "naaptolindex"
95
#Create the Index Writer
96
writer = lucene.IndexWriter(path_index5,analyzer,True) 
97
 
98
phones = da.get_allnaaptolphones()
99
for p in phones:
100
    doc = lucene.Document()
101
    id = p.id
102
    doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
103
    name = p.name
104
    doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
105
    price = p.range 
106
    doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
107
    #print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
108
    writer.addDocument(doc)
109
    #print str(writer.docCount())
110
writer.close()   
111
 
112
 
113
path_index6 = ds+"home"+ds+"gaurav"+ds+"code" + ds + "mobstoreindex"
114
#Create the Index Writer
115
writer = lucene.IndexWriter(path_index6,analyzer,True) 
116
 
117
phones = da.get_allmobstorephones_new()
118
for p in phones:
119
    doc = lucene.Document()
120
    id = p.id
121
    doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
122
    name = p.name
123
    doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
124
    price = p.final_price 
125
    doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
126
    #print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
127
    writer.addDocument(doc)
128
    #print str(writer.docCount())
129
writer.close()