Google-api-nodejs-client: Google Talent Solutions batchDelete request without using OR

Created on 31 Dec 2018  路  8Comments  路  Source: googleapis/google-api-nodejs-client

Node.js verson 8.5
googleapis: version "^33.0.0"

I am attempting to do a batchDelete to delete all the jobs for a particular company (In this example the company only has two jobs for simplicity. I have tried the following requests without luck. The documentation states that you can only use the = and AND operators so I am not sure how one might go about deleting multiple jobs for a single company if you can only use = and AND.

const request = {
  parent: `projects/${process.env.GOOGLE_CLOUD_PROJECT}`,
  requestBody: {
     filter: 'companyName = "companies/xxxxxxxx"'
  }
};
const request = {
  parent: `projects/${process.env.GOOGLE_CLOUD_PROJECT}`,
  requestBody: {
    filter: 'companyName = "companies/xxxxxxxx" AND (requisitionId = "5c1bdd2ffcd03c3af56e3135" OR requisitionId = "5c1bdda5fcd03c3af56e3149")'
  }
};
const request = {
  parent: `projects/${process.env.GOOGLE_CLOUD_PROJECT}`,
  requestBody: {
     filter: 'requisitionId = "5c1bdd2ffcd03c3af56e3135" OR requisitionId = "5c1bdda5fcd03c3af56e3149"'
   }
};

On a whim tried something like

const request = {
  parent: `projects/${process.env.GOOGLE_CLOUD_PROJECT}`,
  requestBody: {
    filter: [
      'companyName = "xxxxxxx" AND requisitionId = "5c1bdd2ffcd03c3af56e3135"',
      'companyName = "xxxxxx" AND requisitionId = "5c1c1081f8f05b6c5a3dc0fe"'
    ]
  }
};
talent question

All 8 comments

The sample here: https://cloud.google.com/talent-solution/job-search/docs/reference/rest/v3/projects.jobs/batchDelete

Has this Sample Query: companyName = "projects/api-test-project/companies/123" AND requisitionId = "req-1" But I don't see how this could translate into a batchDelete

@JustinBeckwith any idea on this? You had helped in the past with examples.....really doesn't make sense to me how you have to supply a companyName and a requisitionId but you can't use OR to do a batch delete...

Anyone have any ideas on this or a batchDelete example? I have 1000's of jobs I need to delete and the API seems to be the only way to do it... but 1-by-1 is no longer proving to be an option

@nwkeeley Just submitted a sample for you to look at. The formatting is something like this:

let batchDeleteQuery = `companyName = "${companyName}"`;
    jobs.forEach(job => {
      batchDeleteQuery += ` AND requisitionId = "${job.requisitionId}"`;
    });

     const request = {
      parent: `projects/${PROJECT_ID}`,
      requestBody: {
        filter: batchDeleteQuery,
      },
    };

where jobs is an array of job objects received from the jobs .list() method. Unfortunately, you'll have to run the sequence for every individual company, but much better than 1-by-1 per job per company. And of course you can add logic between the .list() and .batchDelete() if you're looking for specific jobs.

Hope this helped!

@JCIV-SE thank you for the reply, I never thought to try that syntax. In my mind if I was deleting jobs
companyName = "x" AND requisitionId = "Y" AND requisitionId = "Z" - well from a SQL perspective that wouldn't ... but looking at it from this perspective it can be the only way it would work.

I was all knotted up thinking companyName = "x" AND (requisitionId = "Y" OR requisitionId = "Z")

Again appreciate it - I'll give it a show.

@joecervino why would the above code sample work? If batchDeleteQuery ends up looking like companyName = "x" AND requisitionId = "Y" AND requisitionId = "Z" it just ends up deleting one of Y or Z, but not both. How is that deleting in batch?

Maybe I'm missing something blatantly obvious...

@joecervino why would the above code sample work? If batchDeleteQuery ends up looking like companyName = "x" AND requisitionId = "Y" AND requisitionId = "Z" it just ends up deleting one of Y or Z, but not both. How is that deleting in batch?

Maybe I'm missing something blatantly obvious...

I agree, I tried this using the Python library and companyName = "x" AND requisitionId = "Y" AND requisitionId = "Z" only deletes one record, not two. This is is not a batch delete.

Greetings, we're closing this due to inactivity. Please let us know if the issue needs to be reopened.

Was this page helpful?
0 / 5 - 0 ratings