Skip to content

Commit

Permalink
v0.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ts-thomas committed Feb 2, 2019
1 parent 2d71a6f commit ef846b5
Show file tree
Hide file tree
Showing 9 changed files with 599 additions and 528 deletions.
58 changes: 54 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1559,18 +1559,63 @@ Compare these presets:
- <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/matching-presets.html" target="_blank">Relevance Scoring</a><br>
- <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/benchmark-presets.html" target="_blank">Benchmarks</a>

<a name="builds"></a>
## Best Practices

__Split Complexity__

Whenever you can, try to divide content by categories and add them to its own index, e.g.:

```js
var feeds_2017 = new FlexSearch();
var feeds_2018 = new FlexSearch();
var feeds_2019 = new FlexSearch();
var action = new FlexSearch();
var adventure = new FlexSearch();
var comedy = new FlexSearch();
```

This way you can also provide different settings for each category.

To make this workaround more extendable you can define a tiny helper:
```js
var settings = {};
var index = {};

function add(id, cat, content){
(index[cat] || (
index[cat] = new FlexSearch(settings[cat])
)).add(id, content);
}

function search(cat, query){
return index[cat] ? index[cat].search(query) : [];
}
```

Provide settings optionally (or skip and use defaults):
```js
settings = {
action: "score",
adventure: "match",
comedy: {
encode: "advanced",
tokenize: "forward",
threshold: 5
}
};
```

Add content to the index:
```js
add(1, "action", "Movie Title");
add(2, "adventure", "Movie Title");
add(3, "comedy", "Movie Title");
```

Perform queries:
```js
var results = search("action", "movie title"); // --> [1]
```

Filter queries by categories will hugely improve performance.

__Use numeric IDs__

It is recommended to use numeric id values as reference when adding content to the index. The byte length of passed ids influences the memory consumption significantly. If this is not possible you should consider to use a index table and map the ids with indexes, this becomes important especially when using contextual indexes on a large amount of content.
Expand Down Expand Up @@ -1771,6 +1816,11 @@ __Supported Build Flags__
<td>SUPPORT_PRESETS</td>
<td>true, false</td>
</tr>
<tr></tr>
<tr>
<td>SUPPORT_SERIALIZE</td>
<td>true, false</td>
</tr>
<tr>
<td><br><b>Language Flags </b>(includes stemmer and filter)</td>
<td></td>
Expand Down
1 change: 1 addition & 0 deletions compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var parameter = (function(opt){
export_local_property_definitions: true,
language_in: "ECMASCRIPT6_STRICT",
language_out: language_out || "ECMASCRIPT6_STRICT",
//rewrite_polyfills: false,
process_closure_primitives: true,
summary_detail_level: 3,
warning_level: "VERBOSE",
Expand Down
35 changes: 17 additions & 18 deletions flexsearch.compact.js

Large diffs are not rendered by default.

Loading

0 comments on commit ef846b5

Please sign in to comment.