diff --git a/CHANGELOG.md b/CHANGELOG.md index 3408eb8..9411ff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +#### v0.5.1 + +- Provide customizable scoring resolution + #### v0.5.0 - Where / Find Documents diff --git a/README.md b/README.md index 82fe9ca..ecc5d32 100644 --- a/README.md +++ b/README.md @@ -946,6 +946,33 @@ var index = new FlexSearch({ }); ``` +Using a custom stemmer, e.g.: +```js +var index = new FlexSearch({ + + stemmer: function(value){ + + // apply some replacements + // ... + + return value; + } +}); +``` + +Using a custom filter, e.g.: +```js +var index = new FlexSearch({ + + filter: function(value){ + + // just add values with length > 1 to the index + + return value.length > 1; + } +}); +``` + Or assign stemmer/filters globally to a language: > Stemmer are passed as a object (key-value-pair), filter as an array. @@ -1112,6 +1139,30 @@ var index = new FlexSearch({ }); ``` +You are also able to provide custom presets for each field separately: + +```js +var index = new FlexSearch({ + doc: { + id: "id", + field: { + title: { + encode: "extra", + tokenize: "reverse", + threshold: 7 + }, + cat: { + encode: false, + tokenize: function(val){ + return [val]; + } + }, + content: "memory" + } + } +}); +``` + #### Complex Objects Assume the document array looks more complex (has nested branches etc.), e.g.: @@ -1150,6 +1201,8 @@ var index = new FlexSearch({ }); ``` +> __Hint:__ This is an alternative for indexing documents which are much more complex: https://github.com/nextapps-de/flexsearch/issues/36 + #### Add/Update/Remove Documents to/from the Index Just pass the document array (or a single object) to the index: @@ -1286,6 +1339,8 @@ To get by ID, you can also use short form: index.find(1); ``` +Getting a doc by ID is actually the fastest way to retrieve a result from documents. + Find by a custom function: ```js index.find(function(item){ @@ -1362,7 +1417,7 @@ index.search("foo", { > __IMPORTANT NOTICE:__ This feature will be removed due to the lack of scaling and redundancy. -Tagging is pretty much the same like adding an additional index to a database column. Whenever you use ___where___ on an indexed/tagged attribute will improve performance drastically but also at a cost of additional memory. +Tagging is pretty much the same like adding an additional index to a database column. Whenever you use ___index.where()___ on an indexed/tagged attribute will really improve performance but also at a cost of some additional memory. > The colon notation also has to be applied for tags respectively. @@ -1410,7 +1465,7 @@ Find all documents by an attribute: index.where({"cat": "comedy"}, 10); ``` -Since the attribute "cat" was tagged (has its own index) this expression performs extremely fast. This is actually the fastest way to retrieve results from documents. +Since the attribute "cat" was tagged (has its own index) this expression performs really fast. This is actually the fastest way to retrieve multiple results from documents. Search documents and also apply a where-clause: ```js @@ -1426,7 +1481,7 @@ index.search("foo", { }); ``` -For a better understanding, using the same expression without the where clause has pretty much the same performance. On the other hand, using a where-clause without a tag on its property has an additional cost. +An additional where-clause has a significant cost. Using the same expression without _where_ performs significantly better (depending on the count of matches). ## Custom Sort @@ -1728,7 +1783,7 @@ Tokenizer effects the required memory also as query time and flexibility of part
foobar
foo
barbar
fo
obarfoob
arar
obar
oba
roob
ar