Skip to content

Commit

Permalink
Update readme to accurately reflect what was decided on issue #10
Browse files Browse the repository at this point in the history
See comments here:
#10 (comment)
  • Loading branch information
aguynamedben committed Jan 12, 2018
1 parent 3d6f3e5 commit 32ea463
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions readme.md
Expand Up @@ -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
----------------

Expand Down Expand Up @@ -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
=====

Expand Down

0 comments on commit 32ea463

Please sign in to comment.