hound-search / hound

Lightning fast code searching made easy
MIT License
5.64k stars 575 forks source link

Request for a .hound-exclude file in repo. #445

Open dwright opened 1 year ago

dwright commented 1 year ago

As a repo maintainer, I would really like a way to be able to tell hound not to index certain files inside my repo. And I would like to be able to do so without requiring my git admins to update their global config file.

My suggestion is to support a .hound-exclude file in the top level of the repo that hound would read an honor when indexing. Sort of the equivalent of a robots.txt file for web crawlers. I'd like to be able to specify filenames or directories to exclude.

salemhilal commented 1 year ago

Can you tell us more about your use case? Currently, we have:

I'm not sure about the use case for a repo owner preventing others from searching the contents of the files in the repo, but I'd be open to hear more. Usually, it's up to the person doing the searching to prune things they don't want to see from their query.

dwright commented 1 year ago

My particular use case is for an internal company repo.

There are cases where we have test data, or even some production data that is kept in a repo somewhere. And it's usually not anything that we ever want to search for. But often, it does end up getting caught in our queries and thus increases the noise to signal ratio. I don't want to exclude the whole repo because there is important code in there. But I do want to be able to exclude the test data.

salemhilal commented 1 year ago

Hmm. Having something excluded from Hound's index that isn't excluded from the repo sounds a bit tricky (someone put that data there, so presumably they'd eventually want to search for it), but I see your problem. I'm sure we'd accept a PR for that.

Since we typically filter searches using the exclusion filters in the UI, I wonder if having those fields' contents saved in localstorage would be a good enough solution? That way, you'd filter your results once in the UI and then retain those filters in subsequent searches. That seems like a general improvement to the UI anyways, and it could solve your problem as well.

qyk1995 commented 1 year ago

@salemhilal Filtering in the UI is not easy to control permissions, so it is recommended to configure filtering files or directories in the configuration file. What should we do?