コード例 #1
0
def matchResumes(keywords,
                 experience,
                 location,
                 max_salary,
                 last_time,
                 fields='',
                 start=0,
                 rows=500):
    q = getMatchResumeQuery(keywords, experience, location, max_salary,
                            last_time)
    print q
    s = SearchClient()
    response = s.search(q,
                        fields,
                        CLUSTER_ID,
                        'id',
                        'desc',
                        start=start,
                        rows=rows)
    int_fields = ['experience', 'min_salary', 'rating']
    date_fields = []
    for res in response.results:
        for fld in res.keys():
            if fld in int_fields: res[fld] = unformat.Int(res[fld])
            elif fld in date_fields: res[fld] = unformat.Date(res[fld])

    return response
コード例 #2
0
    def testUpdateIndexes(self):
        s = SearchClient()
        a_fields = {'id':'1',
                    'name':'Jeswin P',
                    'skills':'c#, java',
                    'age': format.Int(28),
                    'date_added': format.Date(datetime.datetime.now()),
                    'fulltext': 'Jeswin P is ideating'}
        a = IndexUpdateEntry('update','1', a_fields)

        b_fields = {'id':'2',
                    'name':'Anup K7',
                    'skills':'c#, java',
                    'age': format.Int(27),
                    'date_added': format.Date(datetime.datetime.now()),
                    'fulltext': 'Anup K7 works on c# and Java'}
        b = IndexUpdateEntry('update','2', b_fields)

        c_fields = {'id':'3',
                    'name':'Alerpa Sherpa',
                    'skills':'c++, Fortran-90, asp.net, OS/390',
                    'age': format.Int(27),
                    'date_added': format.Date(datetime.datetime.now()),
                    'fulltext': 'Anup K7 works on c# and Java'}
        c = IndexUpdateEntry('update','3', c_fields)

        s.updateIndexes([a,b,c], 'solr_test')
コード例 #3
0
ファイル: search_helper.py プロジェクト: jeswin/JobHunt
def matchResumes(keywords, experience, location, max_salary, last_time, fields='', start=0, rows=500):
    q = getMatchResumeQuery(keywords, experience, location, max_salary, last_time)
    print q
    s = SearchClient()
    response = s.search(q, fields, CLUSTER_ID, 'id', 'desc', start=start, rows=rows)
    int_fields = ['experience', 'min_salary', 'rating']
    date_fields = []
    for res in response.results:
        for fld in res.keys():
            if fld in int_fields:   res[fld] = unformat.Int(res[fld])
            elif fld in date_fields:   res[fld] = unformat.Date(res[fld])
            
    return response
コード例 #4
0
def feedResumes(limit_time):
    s = SearchClient()

    #deleted users have to be moved from index
    stmt = "SELECT user_id FROM website_indexdelta WHERE index_type = 'D' AND marked_at < %(limit_time)s;"
    cursor.execute(stmt, {'limit_time': limit_time})
    results = cursor.fetchall()
    deletions = []
    for row in results:
        print 'deleting.. ', str(row[0])
        deletions.append(IndexUpdateEntry('delete', str(row[0])))

    s.updateIndexes(deletions, CLUSTER_ID)

    #indexing the updated users
    stmt = """SELECT U.id, A.account_type, A.username, U.key, (CASE A.account_type WHEN 'FU' THEN U.email WHEN 'PU' THEN U.proxy_email END) As email,
            name, telephone, industry, experience, curr_employer, curr_designation, tags, summary, min_salary, pref_employment,
            pref_designation, pref_location, text_filepath, rating
            FROM website_user U INNER JOIN website_account A ON U.account_id = A.id
            WHERE U.id IN (SELECT user_id FROM website_indexdelta WHERE index_type = 'U' AND marked_at < %(limit_time)s)
            AND A.account_state = 'A' AND U.is_job_hunting = 'yes' ORDER BY U.id;"""
    cursor.execute(stmt, {'limit_time': limit_time})
    results = cursor.fetchall()

    update_list = []
    for (user_id, account_type, username, key, email, name, telephone, industry, experience, curr_employer, curr_designation, \
        tags, summary, min_salary, pref_employment, pref_designation, pref_location, text_filepath, rating) in results:

        if account_type == 'PU' or (account_type == 'FU' and text_filepath
                                    and os.path.exists(text_filepath)):

            meta = {}
            meta['id'] = str(user_id)
            meta['account_type'] = dataplus.decode(account_type)
            meta['username'] = dataplus.decode(username)
            meta['name'] = dataplus.decode(name)
            meta['key'] = dataplus.decode(key)
            meta['email'] = dataplus.decode(email)
            meta['telephone'] = dataplus.decode(telephone)
            meta['industry'] = dataplus.decode(industry)
            meta['experience'] = format.Int(experience)
            meta['curr_employer'] = dataplus.decode(curr_employer)
            meta['curr_designation'] = dataplus.decode(curr_designation)
            meta['tags'] = dataplus.decode(tags)
            meta['summary'] = dataplus.decode(summary)
            meta['min_salary'] = format.Int(min_salary)
            meta['pref_employment'] = dataplus.decode(pref_employment)
            meta['pref_designation'] = dataplus.decode(pref_designation)
            meta['pref_location'] = dataplus.decode(pref_location)
            meta['rating'] = format.Int(rating)
            meta['indexed_on'] = format.Date(limit_time)

            if account_type == 'FU':
                meta['fulltext'] = format.exactFormat(
                    meta['tags'] + dataplus.decode(open(text_filepath).read()))
            elif account_type == 'PU':
                meta['fulltext'] = format.exactFormat(meta['tags'] + '\n' +
                                                      meta['summary'])

            update_list.append(IndexUpdateEntry('update', str(user_id), meta))
            print user_id, dataplus.decode(meta['tags'])

    print 'finished creating meta data'
    #we are updating the Resume Store (store-name:resume)
    s.updateIndexes(update_list, CLUSTER_ID)
    print "updated indexes successfully"
コード例 #5
0
    def testSearch(self):
        s = SearchClient()
        results = s.search('skills:c*', '', 'solr_test')

        for result in results:
            print result
コード例 #6
0
ファイル: search_feed_job.py プロジェクト: jeswin/JobHunt
def feedResumes(limit_time):
    s = SearchClient()
    
    #deleted users have to be moved from index
    stmt = "SELECT user_id FROM website_indexdelta WHERE index_type = 'D' AND marked_at < %(limit_time)s;"
    cursor.execute(stmt, {'limit_time':limit_time})
    results = cursor.fetchall()
    deletions = []
    for row in results:
        print 'deleting.. ', str(row[0])
        deletions.append(IndexUpdateEntry('delete', str(row[0])))
        
    s.updateIndexes(deletions, CLUSTER_ID)

    #indexing the updated users
    stmt = """SELECT U.id, A.account_type, A.username, U.key, (CASE A.account_type WHEN 'FU' THEN U.email WHEN 'PU' THEN U.proxy_email END) As email,
            name, telephone, industry, experience, curr_employer, curr_designation, tags, summary, min_salary, pref_employment,
            pref_designation, pref_location, text_filepath, rating
            FROM website_user U INNER JOIN website_account A ON U.account_id = A.id
            WHERE U.id IN (SELECT user_id FROM website_indexdelta WHERE index_type = 'U' AND marked_at < %(limit_time)s)
            AND A.account_state = 'A' AND U.is_job_hunting = 'yes' ORDER BY U.id;"""
    cursor.execute(stmt, {'limit_time':limit_time})
    results = cursor.fetchall()

    update_list = []
    for (user_id, account_type, username, key, email, name, telephone, industry, experience, curr_employer, curr_designation, \
        tags, summary, min_salary, pref_employment, pref_designation, pref_location, text_filepath, rating) in results:
        
        if account_type == 'PU' or (account_type == 'FU' and text_filepath and os.path.exists(text_filepath)):
            
            meta = {}
            meta['id'] = str(user_id)
            meta['account_type'] = dataplus.decode(account_type)
            meta['username'] = dataplus.decode(username)
            meta['name'] = dataplus.decode(name)
            meta['key'] = dataplus.decode(key)
            meta['email'] = dataplus.decode(email)
            meta['telephone'] = dataplus.decode(telephone)
            meta['industry'] = dataplus.decode(industry)
            meta['experience'] = format.Int(experience)
            meta['curr_employer'] = dataplus.decode(curr_employer)
            meta['curr_designation'] = dataplus.decode(curr_designation)
            meta['tags'] = dataplus.decode(tags)
            meta['summary'] = dataplus.decode(summary)
            meta['min_salary'] = format.Int(min_salary)
            meta['pref_employment'] = dataplus.decode(pref_employment)
            meta['pref_designation'] = dataplus.decode(pref_designation)
            meta['pref_location'] = dataplus.decode(pref_location)
            meta['rating'] = format.Int(rating)
            meta['indexed_on'] = format.Date(limit_time)

            if account_type == 'FU':
                meta['fulltext'] = format.exactFormat(meta['tags'] + dataplus.decode(open(text_filepath).read()))
            elif account_type == 'PU':
                meta['fulltext'] = format.exactFormat(meta['tags'] + '\n' + meta['summary'])
                
            update_list.append(IndexUpdateEntry('update', str(user_id), meta))
            print user_id, dataplus.decode(meta['tags'])

    print 'finished creating meta data'
    #we are updating the Resume Store (store-name:resume)
    s.updateIndexes(update_list, CLUSTER_ID)
    print "updated indexes successfully"