rasa / scoop-directory

A searchable directory of buckets for the scoop package manager for Windows
https://rasa.github.io/scoop-directory/
MIT License
864 stars 76 forks source link

Implementing Search #60

Closed rashil2000 closed 3 years ago

rashil2000 commented 3 years ago

There's still no usable online search index for Scoop, and I'd like to change that. Both scoop.netlify.app/apps and scoop-docs.now.sh/apps are non-functional.

Since scoop-directory already creates a very usable index of all the manifests, let's not reinvent the wheel and use that index itself.

The first step is creating a SQLite database, which has already been done here #19. However, it is hosted in a different place and contains only these fields:

  "name" TEXT,
  "version" TEXT,
  "description" TEXT,
  "license" TEXT,
  "bucket_repo" TEXT

Some more fields will be required, like homepage, link to manifest file etc.

For a proof of concept implementation, I have created this simple HTML file which use SQL.js JavaScript library to run queries in the scoop-directory - poc.txt (simply rename the file to HTML and open it, no install required).

This works, but there are some things that need to be done to make this seamless:

If this looks good to go, I'd like to work on this (though I'll need help, I've never worked with Python before).

Cheers

rashil2000 commented 3 years ago

search.txt

I have created an updated page based on the website's theme.

(GitHub won't let me upload HTML files, so again just rename from .txt to .html and open in browser - no install required).

rashil2000 commented 3 years ago

https://rashil2000.github.io/scoop-directory/search

The search page is now live on my fork

rasa commented 3 years ago

Untested, but this might prove faster/simpler and automatically remove dups:

SELECT name,version,bucket_url,description,manifest_url,homepage,license
FROM apps
WHERE name LIKE "%${query}%"
UNION
SELECT name,version,bucket_url,description,manifest_url,homepage,license
FROM apps
WHERE description LIKE "%${query}%"
ORDER BY 
CASE
  WHEN name LIKE "${query}" OR description LIKE "${query}" THEN 1
  WHEN name LIKE "${query}%" OR description LIKE "${query}%" THEN 2
  WHEN name LIKE "%${query}" OR description LIKE "%${query}" THEN 3
  ELSE 4
END
rashil2000 commented 3 years ago

It gives a syntax error, but I got the gist and did something similar to combine them into a single query.