jeancroy / FuzzySearch

:mag: Fast autocomplete suggestion engine using approximate string matching
MIT License
194 stars 32 forks source link

Search multiple keyword #1

Closed microdevil closed 7 years ago

microdevil commented 8 years ago

Hi...

Beforehand, I am really thank to you because of creating this library. This library help me to search keyword based on similarity. My question :

  1. is this supporting for searching multiple keyword ? I wanna search keyword with "R and B" and "R&B"
  2. is this supporting for searching some keyword like "R and B" => "R&B" ? I wanna improve my searching like 1 => one or 12 => twelve.

"Sorry for my bad grammar" Thanks

jeancroy commented 8 years ago

1) Yes it is. 2) This will not do substitution in the query '&' => 'and' However it allow to search in list, so you can define synonyms

Genres = [
{Name: "R&B", Keywords: ["R&B", "R and B", "Rythm and Blues"] },
{Name: "Rock", Keywords: ["Rock&Rolls", "Rock'n'Rolls"] }
]

var fs =  new FuzzySearch({source:Genres, keys:["Name","Keywords"] });
microdevil commented 8 years ago

Hi @jeancroy Thanks for your fast answer

Is this code for searching multiple keyword ?

var data = ["survey","surgery","insurgence"];
var searcher = new FuzzySearch({source:data});
var query_1 = "keyword_1";
var query_2 = "keyword_2"
var result_1 = searcher.search(query_1, query_2);
// Or 
var result_2 = searcher.search([query_1, query_2]);

I just wanna confirm that my code on the right place

Thanks...

jeancroy commented 8 years ago

Multiple keyword like sentence, separate them by space

var data = ["satisfaction survey","urgent surgery ","apple cider"]; var searcher = new FuzzySearch({source:data}); var results = searcher.search("apple survey");