loilo / Fuse

🔍 Fuzzy search for PHP, ported from Fuse.js
Apache License 2.0
333 stars 30 forks source link

Performance #21

Closed vdgvince2 closed 5 years ago

vdgvince2 commented 5 years ago

Dear,

The library is great and the precision is very good. However, i have performances issues.

I'm running the tool on a list of 15,000 entries (2-3 words per entry, 1 field only) that i want to fuzzy against ifself. Here is my configuration

$thresholdFuzzy = 0.6; // lower down that value to be more strict. 0 = exact match
$FuzzyParameters = [
  "keys" => [ "keywordName"],
  "includeScore" => true,           
  "maxPatternLength" => 32,
  "threshold" => $thresholdFuzzy,
  "minMatchCharLength" => 1
];

$fuse = new \Fuse\Fuse($dataToFuzzyNoExactMatch, $FuzzyParameters);
$results = $fuse->search($kw);

I executed a loop of fuzzy on (the first) 100 entries compared to 15,000. It took 500 seconds to compute.

Any idea how i can improve the speed please?

loilo commented 5 years ago

Hey,

to my knowledge, this is mainly a limition of the PHP runtime. 15,000 records is not a small number and this library does not even keep a search index.

I've investigated this kind of performance issue more deeply in https://github.com/loilo/Fuse/issues/18#issuecomment-477526586 and have come to the conclusion that it's probably not possible to improve in PHP land, at least not if I want to keep this a port of Fuse.js.

Mentioning Fuse.js, I've already suggested

Sorry, I can't help you further with that.