diff --git a/readme.md b/readme.md index 3f5f3f0..50fe909 100644 --- a/readme.md +++ b/readme.md @@ -39,6 +39,23 @@ Then use the method search to perform a search var result = searcher.search(query) ``` +Updating the index +------------------ + +After you create your `searcher`, you can add documents to it using `searcher.add()`. + +```javascript + var data = ["survey","surgery","insurgence"]; + var searcher = new FuzzySearch({source:data}); + var query = "assurance"; + var result = searcher.search(query) + var newEntry = "surgeon"; + searcher.add(newEntry); + var newResult = searcher.search("surgeo"); +``` + +The API also supports more advanced tag-based search. See the `Tagged search` section below. + Twitter typeahead ---------------- @@ -657,20 +674,6 @@ Comparison of some string similarity measurements > https://asecuritysite.com/forensics/simstring -Internal Design -=============== - -Internally, there are 2 main datastructures that are maintained, `this.source` and `this.index`: -* `this.source` - the original source data -* `this.index` - the indexed data for use in searching - -The method `this._prepSource` inspects `this.source` and builds `this.index`. `this._prepSource` add each item in source to `this.index` by calling `this.add()`. `this.add()` in turn calls `this._prepItem()` before adding the item to the index. - -If the `this.dirty` flag is set to `true`, reindexing will happen upon the next search. - -A good summary of how indexing works and how the code is organized can be found in [this issue comment from @jeancroy](https://github.com/jeancroy/FuzzySearch/issues/9#issuecomment-349845521) - - Tests =====