My Hive Posts

    Searching Github Repository on Exact Terms

    Fixing Issue #64 of Utopian-io

    There was a bug posted by @JefPatat that he is not able to find his project openv/openv in the project list.

    image.png

    Analysing the Bug

    Github provides an API for repository search and using Utopian-io we get the list of all the projects in the GitHub which match the terms. Now when I searched the exact same words in Github it provided me more than 14000 projects which matched the term as shown below.

    image.png

    The result is sorted based on the score of the project as well as based on the stars they have received till now. Now in the Utopian we cannot show all the 14000 projects so we need to do the exact search of the name.

    Fixing the Bug

    I have worked on Solr search before so I know that to make a search on exact terms the query should be encoded inside the quotes.

    So instead of using https://api.github.com/search/repositories?q=openv%2Fopenv+fork:true+in:name&sort=stars&order=desc I have used https://api.github.com/search/repositories?q=%22openv%2Fopenv%22+fork:true+in:name&sort=stars&order=desc.

    image.png

    Thus as shown below it gives only 7 records and not all the 14000 records. Only thing you need to keep in mind that you are searching the repository with exact terms.

    Pull Request : https://github.com/utopian-io/utopian.io/pull/76 Commit : https://github.com/codingdefined/utopian.io/commit/0c93e60f498596a05e5586f95acbceb7f1da7e64



    Open Source Contribution posted via Utopian.io