Skip to content

Instantly share code, notes, and snippets.

@nuklehed
nuklehed / gist:0de5d0c4dc3822b36a2350c253017dcf
Last active February 28, 2020 16:16
PHP version of Mongo fuzzy search
<?php
// This is based on a fuzzy search video of a lecture by John L. Page. I am implementing
// a version for 5.8M records in Mongo for a Laravel PHP app. This is working and should
// port to laravel-mongodb using the "raw" method. Not sure if we could do the same thing
// in Eloquent but it shouldn't matter (would only make it look cleaner!)
$m = new \MongoDB\Driver\Manager('mongodb://127.0.0.1:27017');
/*-- May not be using the proper terminology but it makes sense to me :) --
* 1. Match _id's using $or conditional. This means we only want a result if one of values match.