Exemplo n.º 1
0
    def get(self, job_listing_id):
        print("Request for job listing with id: " + job_listing_id)
        listing = get_job_listing_info(job_listing_id)

        es = Elasticsearch()
        es.index(index='joblistings',
                 doc_type='job-listing',
                 id=job_listing_id,
                 body=listing)

        print("Got the following listing as a response: " + listing)
        return listing
    def get(self, job_listing_id):
        print("Request for job listing with id: " + job_listing_id)

        es = Elasticsearch()
        if (es.exists(index='joblistings',
                      doc_type='job-listing',
                      id=job_listing_id)):
            print('Found the document in ElasticSearch')
            doc = es.get(index='joblistings',
                         doc_type='job-listing',
                         id=job_listing_id)
            print(type(doc))
            return doc['_source']

        listing = get_job_listing_info(job_listing_id)
        es.index(index='joblistings',
                 doc_type='job-listing',
                 id=job_listing_id,
                 body=listing)

        print("Got the following listing as a response: " + listing)
        return listing
Exemplo n.º 3
0
 def get(self, job_listing_id):
     print("Request for job listing with id: " + job_listing_id)
     listing = get_job_listing_info(job_listing_id)
     print("Got the following listing as a response: " + listing)
     return listing
from sojobs.scraping import get_job_listing_info
from elasticsearch import Elasticsearch
import json

if __name__ == "__main__":

    es = Elasticsearch(
        [
            "https://*****:*****@7dc72d3327076cc4daf5528103c46a27.us-west-2.aws.found.io:9243"
        ])

    job_ids = ["122517", "163854", "138222", "164641"]

    for job_id in job_ids:
        if not es.exists(index='joblistings', doc_type='job-listing', id=job_id):
            listing = get_job_listing_info(job_id)
            es.index(index='joblistings', doc_type='job-listing', id=job_id, body=listing)

    search_definition = {
        "query": {
            "match": {
                "JSON.skills": {
                    "query": "c# sql",
                    "operator": "AND"
                }
            }
        },
        "_source": ["ID"]
    }

    result = es.search(index="joblistings", doc_type="job-listing", body=search_definition)