| Line 9... |
Line 9... |
| 9 |
|
9 |
|
| 10 |
filePath = '/tmp/autosuggest.json'
|
10 |
filePath = '/tmp/autosuggest.json'
|
| 11 |
destFilePath = '/home/kshitij/'
|
11 |
destFilePath = '/home/kshitij/'
|
| 12 |
|
12 |
|
| 13 |
categoryMap = {3:'Mobiles',5:'Tablets'}
|
13 |
categoryMap = {3:'Mobiles',5:'Tablets'}
|
| 14 |
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3,'SAHOLIC':4,'SHOPCLUES.COM':5}
|
14 |
SOURCE_MAP = {1:'AMAZON',2:'FLIPKART',3:'SNAPDEAL',4:'SAHOLIC',5:"SHOPCLUES.COM",6:"PAYTM.COM",7:"HOMESHOP18.COM"}
|
| 15 |
xstr = lambda s: s or ""
|
15 |
xstr = lambda s: s or ""
|
| 16 |
|
16 |
|
| 17 |
parser = optparse.OptionParser()
|
17 |
parser = optparse.OptionParser()
|
| 18 |
parser.add_option("-m", "--m", dest="mongoHost",
|
18 |
parser.add_option("-m", "--m", dest="mongoHost",
|
| 19 |
default="localhost",
|
19 |
default="localhost",
|
| Line 57... |
Line 57... |
| 57 |
|
57 |
|
| 58 |
def pushData():
|
58 |
def pushData():
|
| 59 |
populateBrandSynonymMap()
|
59 |
populateBrandSynonymMap()
|
| 60 |
populateModelNameSynonyms()
|
60 |
populateModelNameSynonyms()
|
| 61 |
l = []
|
61 |
l = []
|
| - |
|
62 |
exception = []
|
| 62 |
catalogMap = {}
|
63 |
catalogMap = {}
|
| 63 |
items = get_mongo_connection(options.mongoHost).Catalog.MasterData.find({'source_id' : { "$in": SOURCE_MAP.values() } })
|
64 |
items = get_mongo_connection(options.mongoHost).Catalog.MasterData.find({'source_id' : { "$in": SOURCE_MAP.values() } })
|
| 64 |
print items.count()
|
65 |
print items.count()
|
| 65 |
for item in items:
|
66 |
for item in items:
|
| - |
|
67 |
try:
|
| 66 |
title = xstr(item['brand'])+" "+xstr(item['model_name'])
|
68 |
title = xstr(item['brand'])+" "+xstr(item['model_name'])
|
| - |
|
69 |
except:
|
| - |
|
70 |
exception.append(item['_id'])
|
| - |
|
71 |
continue
|
| 67 |
if not catalogMap.has_key(str(item['skuBundleId'])+" "+title):
|
72 |
if not catalogMap.has_key(str(item['skuBundleId'])+" "+title):
|
| 68 |
catalogMap[str(item['skuBundleId'])+" "+title] = [title]
|
73 |
catalogMap[str(item['skuBundleId'])+" "+title] = [title]
|
| 69 |
s_info = __SkuInfo(str(item['_id']),int(item['skuBundleId']),(item['brand']),(item['model_name']),(item['source_product_name']),int(item['category_id']),categoryMap.get(item['category_id']),float(item['available_price']),float(item['mrp']),item['in_stock'], \
|
74 |
s_info = __SkuInfo(str(item['_id']),int(item['skuBundleId']),(item['brand']),(item['model_name']),(item['source_product_name']),int(item['category_id']),categoryMap.get(item['category_id']),float(item['available_price']),float(item['mrp']),item['in_stock'], \
|
| 70 |
int(item['source_id']),(item['source']),title,(item['thumbnail']), long(item['priceUpdatedOn']), synonymsMap.get(item['brand'].upper()), modelNameSynonymMap.get(item['skuBundleId']))
|
75 |
int(item['source_id']),(item['source']),title,(item['thumbnail']), long(item['priceUpdatedOn']), synonymsMap.get(item['brand'].upper()), modelNameSynonymMap.get(item['skuBundleId']))
|
| 71 |
l.append(s_info.__dict__)
|
76 |
l.append(s_info.__dict__)
|
| 72 |
solr.add(l,boost={'source_product_name': '2.0',})
|
77 |
solr.add(l,boost={'source_product_name': '2.0',})
|
| 73 |
|
78 |
|
| - |
|
79 |
|
| - |
|
80 |
for x in exception:
|
| - |
|
81 |
print x
|
| - |
|
82 |
|
| 74 |
autoSuggestList = []
|
83 |
autoSuggestList = []
|
| 75 |
for v in catalogMap.itervalues():
|
84 |
for v in catalogMap.itervalues():
|
| 76 |
autoSuggestList.append({'val':v[0]})
|
85 |
autoSuggestList.append({'val':v[0]})
|
| 77 |
PATH = os.path.expanduser(filePath)
|
86 |
PATH = os.path.expanduser(filePath)
|
| 78 |
if os.path.isfile(PATH):
|
87 |
if os.path.isfile(PATH):
|
| Line 113... |
Line 122... |
| 113 |
print e
|
122 |
print e
|
| 114 |
return None
|
123 |
return None
|
| 115 |
return con
|
124 |
return con
|
| 116 |
|
125 |
|
| 117 |
if __name__=='__main__':
|
126 |
if __name__=='__main__':
|
| 118 |
pushData()
|
- |
|
| 119 |
|
127 |
pushData()
|
| - |
|
128 |
|