Subversion Repositories SmartDukaan

Rev

Rev 18089 | Rev 18271 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18089 Rev 18106
Line 2400... Line 2400...
2400
    except:
2400
    except:
2401
        return {'msg':"Unable to update data",'response':0}
2401
        return {'msg':"Unable to update data",'response':0}
2402
    
2402
    
2403
def getDealsForSearchText(subCategoryIds, searchTerm, offset, limit):
2403
def getDealsForSearchText(subCategoryIds, searchTerm, offset, limit):
2404
    subCategories= [int(subCategoryId) for subCategoryId in subCategoryIds.split('^')]
2404
    subCategories= [int(subCategoryId) for subCategoryId in subCategoryIds.split('^')]
-
 
2405
    print "SubCategories are ",subCategories
2405
    payload = {
2406
    payload = {
2406
      "query": {
2407
    "query": {
2407
        "bool": {
2408
        "bool": {
2408
          "must": [
2409
            "must": [{
2409
            {
-
 
2410
              "match": {
2410
                    "match": {
2411
                    "title": {
2411
                        "title": {
2412
                    "query": searchTerm, 
2412
                            "query": searchTerm,
2413
                    "operator": "and"
2413
                            "operator": "and"
-
 
2414
                        }
-
 
2415
                    }
-
 
2416
                },
-
 
2417
 
-
 
2418
                {
-
 
2419
                    "in": {
-
 
2420
                        "subCategoryId": subCategories
2414
                    }
2421
                    }
2415
               }
-
 
2416
            },
-
 
2417
            {
-
 
2418
              "match": {
-
 
2419
                "subCategoryId": {
-
 
2420
                  "query": subCategories
-
 
2421
                }
2422
                }
2422
              }
2423
 
2423
            }
2424
            ]
2424
          ]
-
 
2425
        }
2425
        }
2426
      }
-
 
2427
    }
2426
    }
2428
    
2427
}
2429
    result =  get_elastic_search_connection().search(index="my_index", body=payload, from_=offset, size=limit)
2428
    result =  get_elastic_search_connection().search(index="my_index", body=payload, from_=offset, size=limit)
2430
    totalCount= result['hits']['total']
2429
    totalCount= result['hits']['total']
2431
    temp = []
2430
    temp = []
2432
    bundles = []
2431
    bundles = []
2433
    if len(result['hits']['hits']) > 0:
2432
    if len(result['hits']['hits']) > 0:
Line 2439... Line 2438...
2439
    return getDealsForNotification(bundles, skipSplitting=True)
2438
    return getDealsForNotification(bundles, skipSplitting=True)
2440
 
2439
 
2441
def getCountForSearchText(subCategoryIds, searchTerm):
2440
def getCountForSearchText(subCategoryIds, searchTerm):
2442
    subCategories= [int(subCategoryId) for subCategoryId in subCategoryIds.split('^')]
2441
    subCategories= [int(subCategoryId) for subCategoryId in subCategoryIds.split('^')]
2443
    payload = {
2442
    payload = {
2444
      "query": {
2443
    "query": {
2445
        "bool": {
2444
        "bool": {
2446
          "must": [
2445
            "must": [{
2447
            {
-
 
2448
              "match": {
2446
                    "match": {
2449
                    "title": {
2447
                        "title": {
2450
                    "query": searchTerm, 
2448
                            "query": searchTerm,
2451
                    "operator": "and"
2449
                            "operator": "and"
-
 
2450
                        }
-
 
2451
                    }
-
 
2452
                },
-
 
2453
 
-
 
2454
                {
-
 
2455
                    "in": {
-
 
2456
                        "subCategoryId": subCategories
2452
                    }
2457
                    }
2453
               }
-
 
2454
            },
-
 
2455
            {
-
 
2456
              "match": {
-
 
2457
                "subCategoryId": {
-
 
2458
                  "query": subCategories
-
 
2459
                }
2458
                }
2460
              }
2459
 
2461
            }
2460
            ]
2462
          ]
-
 
2463
        }
2461
        }
2464
      }
-
 
2465
    }
2462
    }
-
 
2463
}
2466
    
2464
    
2467
    result =  get_elastic_search_connection().search(index="my_index", body=payload)
2465
    result =  get_elastic_search_connection().search(index="my_index", body=payload)
2468
    totalCount= result['hits']['total']
2466
    totalCount= result['hits']['total']
2469
    return {'searchTerm':searchTerm,'count':totalCount}
2467
    return {'searchTerm':searchTerm,'count':totalCount}
2470
            
2468
            
2471
def main():
2469
def main():
-
 
2470
    "8-cable , 15- charger, 20-screen guard"
-
 
2471
    
2472
    print getSubCategoryForFilter(6)
2472
    res = getCountForSearchText("20^8","iph")
2473
    
2473
    
2474
if __name__=='__main__':
2474
if __name__=='__main__':
2475
    main()
2475
    main()
2476
 
2476
 
2477
 
2477