Automattic / kue

Kue is a priority job queue backed by redis, built for node.js.
http://automattic.github.io/kue
MIT License
9.46k stars 867 forks source link

Search active jobs #602

Open btmdave opened 9 years ago

btmdave commented 9 years ago

I see that with the UI there's /job/search?q= to perform a search on data properties within a job. But is there a method within kue or api to search and by active? For example, something like this would be very useful.

queue.search({status: 'active', data: {key : 'something', anotherkey : 'somethingelse'}})

behrad commented 9 years ago

indexes are currently blinded created from the job.data. That can be a feature to index also job states... low priority until we get to an stable search index

bobmoff commented 9 years ago

+1 for being able to find jobs by data.

behrad commented 9 years ago

you currently can search job data ( even define which fields to index) if you disableSearch: false, please read the related section of README @bobmoff

bobmoff commented 9 years ago

sorry for not being clear. i ment like @btmdave was suggesting. through the queue object.

the search you are talking about is through the express http api right ?

btmdave commented 9 years ago

Just to re-iterate the use case, we don't generally use the kue ui, so as-is, there's no way to perform a search. I can get active jobs using kue.jobs.active or complete jobs with kue.jobs.complete etc. The only missing piece would be a kue.jobs.search, which for that we've had to run kue ui and make an http request to the api to /job/search?q=

behrad commented 9 years ago

you can create a PR adding a search method to Queue object like https://github.com/Automattic/kue/blob/master/lib/http/routes/json.js#L269

KATT commented 9 years ago

+1 on searching on data.

I only ever have to search based on one specific key in my data structure, so might be able to work around it by only having that key in searchKeys.

Not very pretty though.

If I have a key in my data which is consistent, is there another way of finding jobs based on that key? Considering looping through all jobs to achieve it.

sanchitbansal10 commented 5 years ago

I wrote an article that might help solving this issue: https://medium.com/@sanchitbansal10/search-kue-jobs-by-job-data-c33972c04c6c