You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1101,6 +1103,69 @@ const result = index.search("a short query", {
1101
1103
});
1102
1104
```
1103
1105
1106
+
## Result Highlighting
1107
+
1108
+
Result highlighting could be just enabled when using Document-Index with enabled Data-Store. Also when you just want to add id-content-pairs you'll need to use a DocumentIndex for this feature (just define a simple document descriptor as shown below).
1109
+
1110
+
```js
1111
+
// create the document index
1112
+
constindex=newDocument({
1113
+
document: {
1114
+
store:true,
1115
+
index: [{
1116
+
field:"title",
1117
+
tokenize:"forward",
1118
+
encoder:Charset.LatinBalance
1119
+
}]
1120
+
}
1121
+
});
1122
+
1123
+
// add data
1124
+
index.add({
1125
+
"id":1,
1126
+
"title":"Carmencita"
1127
+
});
1128
+
index.add({
1129
+
"id":2,
1130
+
"title":"Le clown et ses chiens"
1131
+
});
1132
+
1133
+
// perform a query
1134
+
constresult=index.search({
1135
+
query:"karmen or clown or not found",
1136
+
suggest:true,
1137
+
// set enrich to true (required)
1138
+
enrich:true,
1139
+
// highlight template
1140
+
// $1 is a placeholder for the matched partial
1141
+
highlight:"<b>$1</b>"
1142
+
});
1143
+
```
1144
+
1145
+
The result will look like:
1146
+
1147
+
```js
1148
+
[{
1149
+
"field":"title",
1150
+
"result": [{
1151
+
"id":1,
1152
+
"doc": {
1153
+
"id":1,
1154
+
"title":"Carmencita"
1155
+
},
1156
+
"highlight":"<b>Carmen</b>cita"
1157
+
},{
1158
+
"id":2,
1159
+
"doc": {
1160
+
"id":2,
1161
+
"title":"Le clown et ses chiens"
1162
+
},
1163
+
"highlight":"Le <b>clown</b> et ses chiens"
1164
+
}
1165
+
]
1166
+
}]
1167
+
```
1168
+
1104
1169
## Big In-Memory Keystores
1105
1170
1106
1171
The default maximum keystore limit for the In-Memory index is 2^24 of distinct terms/partials being stored (so-called "cardinality"). An additional register could be enabled and is dividing the index into self-balanced partitions.
@@ -1560,7 +1625,7 @@ You can overcome this issue by passing the filepath to the worker file like `wor
1560
1625
Fuzzysearch describes a basic concept of how making queries more tolerant. FlexSearch provides several methods to achieve fuzziness:
1561
1626
1562
1627
1. Use a tokenizer: `forward`, `reverse` or `full`
1563
-
2. Don't forget to use any of the builtin encoder `simple` > `balanced` > `advanced` > `extra` > `soundex` (sorted by fuzziness)
1628
+
2. Don't forget to use any of the builtin encoder `simple` > `balance` > `advanced` > `extra` > `soundex` (sorted by fuzziness)
1564
1629
3. Use one of the language specific presets e.g. `/lang/en.js` for en-US specific content
1565
1630
4. Enable suggestions by passing the search option `suggest: true`
1566
1631
@@ -1573,13 +1638,13 @@ Original term which was indexed: "Struldbrugs"
1573
1638
<table>
1574
1639
<tr>
1575
1640
<th align="left">Encoder:</th>
1576
-
<th><code>exact</code></th>
1577
-
<th><code>default</code></th>
1578
-
<th><code>simple</code></th>
1579
-
<th><code>balance</code></th>
1580
-
<th><code>advanced</code></th>
1581
-
<th><code>extra</code></th>
1582
-
<th><code>soundex</code></th>
1641
+
<th><code>LatinExact</code></th>
1642
+
<th><code>LatinDefault</code></th>
1643
+
<th><code>LatinSimple</code></th>
1644
+
<th><code>LatinBalance</code></th>
1645
+
<th><code>LatinAdvanced</code></th>
1646
+
<th><code>LatinExtra</code></th>
1647
+
<th><code>LatinSoundex</code></th>
1583
1648
</tr>
1584
1649
<tr>
1585
1650
<th align="left">Index Size</th>
@@ -1694,7 +1759,7 @@ If you get some good results please feel free to share your encoder.
1694
1759
1695
1760
> This is an experimental feature with limited support which probably might drop in future release. You're welcome to give some feedback.
1696
1761
1697
-
When using Server-Side-Rendering you can create a different export which instantly boot up. Especially when using Server-side rendered content, this could help to restore a __static__ index on page load. Document-Indexes aren't supported yet for this method.
1762
+
When using Server-Side-Rendering you can create a different export which instantly boot up. Especially when using Server-side rendered content, this could help to restore a __<u>static</u>__ index on page load. Document-Indexes aren't supported yet for this method.
1698
1763
1699
1764
> When your index is too large you should use the default export/import mechanism.
1700
1765
@@ -1720,7 +1785,7 @@ function inject(index){
1720
1785
}
1721
1786
```
1722
1787
1723
-
You could store this function by e.g. `fs.writeFileSync("inject.js", fn_string);` or place it as string in your markup.
1788
+
You can save this function by e.g. `fs.writeFileSync("inject.js", fn_string);` or place it as string in your SSR-generated markup.
1724
1789
1725
1790
After creating the index on client side just call the inject method like:
1726
1791
@@ -2201,7 +2266,7 @@ The custom build will be saved to `dist/flexsearch.custom.xxxx.min.js` or when f
2201
2266
2202
2267
### Misc
2203
2268
2204
-
A formula to determine a wellbalanced value for the `resolution` is: $2*floor(\sqrt{content.length})$ where content is the value pushed by `index.add()`. Here the maximum length of all contents should be used.
2269
+
A formula to determine a well-balanced value for the `resolution` is: $2*floor(\sqrt{content.length})$ where content is the value pushed by `index.add()`. Here the maximum length of all contents should be used.
0 commit comments