@@ -134,16 +134,46 @@ JsSearch.StopWordsMap.bob = true; // Treat "bob" as a stop word
134134Note that stop words are lower case and so using a case-sensitive sanitizer may prevent some stop words from being
135135removed.
136136
137- ### TF-IDF ranking
137+ ### Configuring the search index
138+
139+ There are two search indices packaged with ` js-search ` .
138140
139141Term frequency–inverse document frequency (or TF-IDF) is a numeric statistic intended to reflect how important a word
140142(or words) are to a document within a corpus. The TF-IDF value increases proportionally to the number of times a word
141143appears in the document but is offset by the frequency of the word in the corpus. This helps to adjust for the fact that
142144some words (e.g. and, or, the) appear more frequently than others.
143145
144146By default Js Search supports TF-IDF ranking but this can be disabled for performance reasons if it is not required. You
145- can specify an alternate ` ISearchIndex ` implementation in order to disable TF-IDF, like so:
147+ can specify an alternate [ ` ISearchIndex ` ] ( https://github.com/wuweiweiwu/js-search/blob/master/source/SearchIndex/SearchIndex.js )
148+ implementation in order to disable TF-IDF, like so:
146149
147150``` javascript
151+ // default
152+ search .searchIndex = new JsSearch.TfIdfSearchIndex ();
153+
154+ // Search index capable of returning results matching a set of tokens
155+ // but without any meaningful rank or order.
148156search .searchIndex = new JsSearch.UnorderedSearchIndex ();
149157```
158+
159+ ### Configuring the index strategy
160+
161+ There are three index strategies packaged with ` js-search ` .
162+
163+ ` PrefixIndexStrategy ` indexes for prefix searches
164+ (e.g. the term "cat" is indexed as "c", "ca", and "cat" allowing prefix search lookups).
165+
166+ ` AllSubstringsIndexStrategy ` indexes for all substrings. In other word "c", "ca", "cat", "a", "at", and "t" all match "cat".
167+
168+ ` ExactWordIndexStrategy ` indexes for exact word matches. For example "bob" will match "bob jones".
169+
170+ ``` javascript
171+ // default
172+ search .indexStrategy = new JsSearch.PrefixIndexStrategy ();
173+
174+ // this index strategy is built for all substrings matches.
175+ search .indexStrategy = new JsSearch.AllSubstringsIndexStrategy ();
176+
177+ // this index strategy is built for exact word matches.
178+ search .indexStrategy = new JsSearch.ExactWordIndexStrategy ();
179+ ```
0 commit comments