Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzzy search #43

Closed
ajford opened this issue Oct 3, 2013 · 2 comments
Closed

Fuzzy search #43

ajford opened this issue Oct 3, 2013 · 2 comments
Assignees
Labels

Comments

@ajford
Copy link

ajford commented Oct 3, 2013

One thing I've found missing from ppl is the ability to search (outside of Mutt).

I'd like to be able to do something like:

$ ppl search john
jdoe: John Doe <jdoe@example.com>
jsmith: John Smith <jsmith@foo.example.com>
mjohn: Matthew John <mjohn@bar.example.com>

Or even fuzzier:

$ ppl search jo
jdoe: John Doe <jdoe@example.com>
jsmith: John Smith <jsmith@foo.example.com>
jj: Joe Johnson <jj@example.com>

I have a lot of contacts, and I don't always remember everybody's id, which usually results in me running ppl ls | grep jo which works, but isn't as elegant, and I'm assuming not as fast as it could be.

What do you think?

@henrycatalinismith
Copy link
Owner

I like this idea a lot, thanks for suggesting it :)

I'll make it happen.

@henrycatalinismith
Copy link
Owner

When I sat down to build this, I began to envision a number of problems with building my own DIY search system.

  • If the search string is present among the attributes of the contact, but isn't present in the output of ppl ls, should that contact be displayed in the output of the search?
  • If the answer to the question above is "yes", do I write some sort of algorithm that cleverly determines which attributes to include in the output based on which ones match the search?
  • Otherwise, do I implement a whole bunch of option flags for users to control the search space of their searches so that there can be no unintended matches?

Besides that, parsing every single contact's vCard and iterating through and examining them all seems like something that isn't going to increase ppl's already underwhelming speed.

So I've gone the simple route, and added a command called ppl grep. This command does almost nothing for itself, instead simply delegating all your input options and arguments to git grep. There are several benefits with this approach:

  • git grep is orders of magnitude faster than anything I could ever hope to implement myself.
  • Output always includes the matching line, making it clear which piece of contact data matched your search string
  • Regular expression searching is possible without me having to build anything
  • Case-sensitivity is optional, again without requiring any work on my part
  • Output is paged if it exceeds screen height

I know this isn't exactly what you asked for, but it's an approach that gives you the maximum performance and flexibility with the minimum possible development time on my part, so it was too good an option for me to pass up. I hope it meets your needs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants