Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support lucene search #101

Open
jamlevi opened this issue Jul 24, 2014 · 7 comments
Open

support lucene search #101

jamlevi opened this issue Jul 24, 2014 · 7 comments

Comments

@jamlevi
Copy link

jamlevi commented Jul 24, 2014

Often, we need to get_latest_version so we call get_artifact_info and we do get the latest version - chronologically. But, what if I want the latest version on a branch and another branch has a newer version. The result returns the latest, but not lexically. Is there currently a way to do that? I don't see one, but it looks like the lucene search can do this if one passes a branch.* wildcard like this:

hxxps://your.nexus.here/nexus/service/local/lucene/search?g=com.mycompany&a=myartifact&repositoryId=releases&v=4.6.*

I think, to support this, I can just add a new artifact_task method like this ?

def search_artifacts_lucene(coordinates)
  artifact = Artifact.new(coordinates)

  query = {:g => artifact.group_id, :a => artifact.artifact_id, :e => artifact.extension, :v => artifact.version,
           :r => configuration['repository']}
  query.merge!({:c => artifact.classifier}) unless artifact.classifier.nil?
  response = nexus.get(nexus_url("service/local/artifact/lucene/search"), query)
  puts response.inspect
  case response.status
    when 200
      return response.content
    else
      raise UnexpectedStatusCodeException.new(response.status)
  end
end

Thanks.

@jamlevi
Copy link
Author

jamlevi commented Jul 24, 2014

Adding that search_for_artifacts only supports group:artifactId so it cannot be used.

@capoferro
Copy link
Contributor

Sounds reasonable... think you could get a pull request together for this feature?

@jamlevi
Copy link
Author

jamlevi commented Jul 25, 2014

Yes. I'll give it a shot.

On Thu, Jul 24, 2014 at 4:58 PM, Josiah Kiehl (formerly @bluepojo) <
[email protected]> wrote:

Sounds reasonable... think you could get a pull request together for this
feature?


Reply to this email directly or view it on GitHub
#101 (comment).

@jamlevi
Copy link
Author

jamlevi commented Jul 29, 2014

I made a commit on my fork jamlevi@d0711b3

It supports only gaecv coordinates and returns a big xml blob. To support all the permutations here, https://repository.sonatype.org/nexus-indexer-lucene-plugin/default/docs/path__lucene_search.html, I would have had to rewrite Artifact and I see that a "Refactor api big time" PR #72 is out there and open, so I decided to wait.

I can certainly issue the PR for the couple methods added?

@KAllan357
Copy link
Contributor

Don't worry about that #72, its been a while and I don't think I'll ever find the time to fix it up. We would certainly accept a pull-request for this functionality, though.

@jamlevi
Copy link
Author

jamlevi commented Jul 30, 2014

K, I fired the PR. Let me know if it needs anything. Also, I didn't really get how that map was used in lib/nexus_cli/tasks.rb, so it's basically a copy, edit, paste job.

@dashirov
Copy link

Does the PR support paging? I have a huge problem - I have to pull latest versions of all artifacts under a common groupId (400+ unique artifacts) without paging nexus returns the first 200 non-unique entries (multiple versions of the same artifatId). Any suggestions?

The initial request would have a header stating how many results are out there:
so if the first request is made with from=1&count=200 then the initial response would provide totalCount that might exceed 200. From that point, one can go into paging mode asking for 200 entry increments until the total is exhausted.

<searchNGResponse>
<totalCount>736</totalCount>
<from>700</from>
<count>200</count>
<tooManyResults>false</tooManyResults>
<collapsed>false</collapsed>
....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants