jenkinsci / lucene-search-plugin

Jenkins plugin for searching job data via Lucene or Solr
https://plugins.jenkins.io/lucene-search
MIT License
5 stars 12 forks source link

removeBuild removes the right build by using run-specific query #15

Closed hmarkc closed 3 years ago

hmarkc commented 3 years ago

removeBuild function in org.jenkinsci.plugins.lucene.search.databackend was using run ID to identify the old run index to be deleted. However, this is not correct. As specified by https://javadoc.jenkins-ci.org/hudson/model/Run.html, run type should always be used in conjuction with the job type. Therefore, this major error results in the wrong index to be deleted and there are missing search results.

I add a function called getRunQuery which returns the correct query for a run. Now removeBuild works as expected and will not wrongly delete the run index of another job.

I make removeBuild to return null for now as I think it is not appropriate to return an old doc and use it when the provided field value is null. This will result in inconsistency. However, this is another issue and I will solve that in another commit.

hmarkc commented 3 years ago

Already solved