| 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
|
| 293 |
ashish |
19 |
index = os.getcwd()
|
|
|
20 |
path_index1 = index + ds + "infibeamindex"
|
| 278 |
ashish |
21 |
#Create the Index Writer
|
|
|
22 |
writer = lucene.IndexWriter(path_index1,analyzer,True)
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
phones = da.get_all_infibeam_data()
|
|
|
26 |
for p in phones:
|
|
|
27 |
doc = lucene.Document()
|
|
|
28 |
id = p.id
|
|
|
29 |
doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
|
|
30 |
name = p.name
|
|
|
31 |
doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
|
|
|
32 |
price = p.final_price
|
|
|
33 |
doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
| 285 |
ashish |
34 |
#print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
|
| 278 |
ashish |
35 |
writer.addDocument(doc)
|
| 285 |
ashish |
36 |
#print str(writer.docCount())
|
|
|
37 |
writer.close()
|
| 278 |
ashish |
38 |
|
| 293 |
ashish |
39 |
path_index2 = index + ds + "indiaplazaindex"
|
| 285 |
ashish |
40 |
#Create the Index Writer
|
|
|
41 |
writer = lucene.IndexWriter(path_index2,analyzer,True)
|
| 278 |
ashish |
42 |
|
| 285 |
ashish |
43 |
phones = da.get_all_indiaplaza_phones()
|
|
|
44 |
for p in phones:
|
|
|
45 |
doc = lucene.Document()
|
|
|
46 |
id = p.id
|
|
|
47 |
doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
|
|
48 |
name = p.p_name
|
|
|
49 |
doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
|
|
|
50 |
price = p.p_final_price
|
|
|
51 |
doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
|
|
52 |
#print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
|
|
|
53 |
writer.addDocument(doc)
|
|
|
54 |
#print str(writer.docCount())
|
|
|
55 |
writer.close()
|
|
|
56 |
|
|
|
57 |
|
| 293 |
ashish |
58 |
path_index3 = index + ds + "univercellindex"
|
| 285 |
ashish |
59 |
#Create the Index Writer
|
|
|
60 |
writer = lucene.IndexWriter(path_index3,analyzer,True)
|
|
|
61 |
|
|
|
62 |
phones = da.get_all_univercell_phones()
|
|
|
63 |
for p in phones:
|
|
|
64 |
doc = lucene.Document()
|
|
|
65 |
id = p.id
|
|
|
66 |
doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
|
|
67 |
name = p.p_title
|
|
|
68 |
doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
|
|
|
69 |
price = p.p_final_price
|
|
|
70 |
doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
|
|
71 |
#print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
|
|
|
72 |
writer.addDocument(doc)
|
|
|
73 |
#print str(writer.docCount())
|
|
|
74 |
writer.close()
|
|
|
75 |
|
|
|
76 |
|
| 293 |
ashish |
77 |
path_index4 = index + ds + "babuchakindex"
|
| 285 |
ashish |
78 |
#Create the Index Writer
|
|
|
79 |
writer = lucene.IndexWriter(path_index4,analyzer,True)
|
|
|
80 |
|
|
|
81 |
phones = da.get_allbabuchakphones()
|
|
|
82 |
for p in phones:
|
|
|
83 |
doc = lucene.Document()
|
|
|
84 |
id = p.id
|
|
|
85 |
doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
|
|
86 |
name = p.name
|
|
|
87 |
doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
|
|
|
88 |
price = p.final_price
|
|
|
89 |
doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
|
|
90 |
#print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
|
|
|
91 |
writer.addDocument(doc)
|
|
|
92 |
#print str(writer.docCount())
|
|
|
93 |
writer.close()
|
|
|
94 |
|
| 293 |
ashish |
95 |
path_index5 = index + ds + "naaptolindex"
|
| 285 |
ashish |
96 |
#Create the Index Writer
|
|
|
97 |
writer = lucene.IndexWriter(path_index5,analyzer,True)
|
|
|
98 |
|
|
|
99 |
phones = da.get_allnaaptolphones()
|
|
|
100 |
for p in phones:
|
|
|
101 |
doc = lucene.Document()
|
|
|
102 |
id = p.id
|
|
|
103 |
doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
|
|
104 |
name = p.name
|
|
|
105 |
doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
|
|
|
106 |
price = p.range
|
|
|
107 |
doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
|
|
108 |
#print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
|
|
|
109 |
writer.addDocument(doc)
|
|
|
110 |
#print str(writer.docCount())
|
|
|
111 |
writer.close()
|
|
|
112 |
|
|
|
113 |
|
| 293 |
ashish |
114 |
path_index6 = index + ds + "mobstoreindex"
|
| 285 |
ashish |
115 |
#Create the Index Writer
|
|
|
116 |
writer = lucene.IndexWriter(path_index6,analyzer,True)
|
|
|
117 |
|
|
|
118 |
phones = da.get_allmobstorephones_new()
|
|
|
119 |
for p in phones:
|
|
|
120 |
doc = lucene.Document()
|
|
|
121 |
id = p.id
|
|
|
122 |
doc.add(lucene.Field("ID",str(id),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
|
|
123 |
name = p.name
|
|
|
124 |
doc.add(lucene.Field("name",name,lucene.Field.Store.YES,lucene.Field.Index.TOKENIZED))
|
|
|
125 |
price = p.final_price
|
|
|
126 |
doc.add(lucene.Field("price",str(price),lucene.Field.Store.YES,lucene.Field.Index.NO))
|
|
|
127 |
#print "id " + str(doc.getField("ID")) + " name " + str(doc.getField("name")) + " price " + str(doc.getField("price"))
|
|
|
128 |
writer.addDocument(doc)
|
|
|
129 |
#print str(writer.docCount())
|
|
|
130 |
writer.close()
|