3

I am trying to search a large number of repositories with "searchRepository" method in https://github.com/eclipse/egit-github/tree/master/org.eclipse.egit.github.core

However, there is a limitation to get more than 1000 results

https://developer.github.com/v3/search/#about-the-search-api

Since it will throw an exception "Only the first 1000 search results are available (422)" (based on the code example below)

A solution is presented in github search limit results

My question is how can I split up the search into segments by the date (as mentioned in the thread), or is there a another way to do this with the Java GitHub API.

    int countRepos = 0;
    Map<String, String> searchQuery = new HashMap<String, String>();
    searchQuery.put("language", "java");
    List<SearchRepository> searchRes = null;
    GitHubClient client = new GitHubClient();
    client.setCredentials("xxx", "xxxxx");
    RepositoryService service = new RepositoryService(client);
    for(int page = 1 ; page <12 ; page++){
        try {
            searchRes = service.searchRepositories(searchQuery,page);
        } catch (IOException e) {
            e.printStackTrace();
        }
        for(SearchRepository repo : searchRes){
                System.out.println("Repository"+countRepos+": "+repo.getOwner()+"/"+repo.getName());
                countRepos++;
        }

    }
    System.out.println("Total number of repositories are="+countRepos);

Thanks in advance.

Community
  • 1
  • 1
user225008
  • 123
  • 2
  • 8

0 Answers0