I am working on a search system for a database of git commits. I am currently using full text search to enable a user to search by author, commit date, the log message, and commit hash. Currently, the commit hash is only useful if the user provides the entire commit hash, which is long and hard to remember, but useful for specifying a single commit.
The query for querying the database is essentially this:
SELECT
cid,
(ts_rank(tsv, q) + ts_rank_cd(tsv, q)) AS rank
FROM
search,
plainto_tsquery(%(query)s) AS q
WHERE
(tsv @@ q);
where cid is the commit hash and the tsv is the text search vector of relevant information for each commit.
My goal is to allow users to only provide a portion of the commit hash in their query, and provide all commits that basically follow from their input.
I've looked into trigrams, which look the most promising, but I'm not entirely sure how to integrate them into this query.