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
Copy file name to clipboardExpand all lines: README.md
+18-2Lines changed: 18 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,8 @@ const engine = new SearchEngine({
51
51
excludeKeys: ['name', 'tags'],
52
52
allowNumericString:false,
53
53
allowKeyValueMatching:true,
54
-
matchChildKeysAsValues:false
54
+
matchChildKeysAsValues:false,
55
+
maxLevels:5
55
56
})
56
57
57
58
constresults=engine.search(users, 'age~: 25-35')
@@ -68,6 +69,10 @@ The `SearchOptions` object allows you to customize the behavior of the search en
68
69
|`allowNumericString`|`boolean`|`true`| Controls whether string values that can be parsed as numbers are used in range searches. |
69
70
|`allowKeyValueMatching`|`boolean`|`true`| When enabled, unquoted terms without a field/value separator match both field names and values. |
70
71
|`matchChildKeysAsValues`|`boolean`|`false`| When enabled, after finding a matching key, also looks for the value in child object keys. |
72
+
|`maxLevels`|`number`| unlimited | Maximum levels of nested objects to search through. Useful to avoid infinite loops in deeply nested or circular data. |
73
+
74
+
### Notes
75
+
- The `maxLevels` option can be set to limit how deep the search will go into nested objects. This is especially useful for large or circular data structures.
71
76
72
77
### Differences Between Options
73
78
@@ -98,7 +103,17 @@ The `SearchOptions` object allows you to customize the behavior of the search en
98
103
-`field~: 10-` - Numbers greater than or equal to 10.
99
104
-`field~: -20` - Numbers less than or equal to 20.
100
105
101
-
Negative values are also supported.
106
+
### "Is / Is Not" Operators
107
+
108
+
-`field is value` - Search for objects where `field` is exactly `value`.
109
+
-`field is not value` - Search for objects where `field` is not `value`.
110
+
111
+
Where `value` must be one of the following:
112
+
- A boolean (`true` or `false`)
113
+
-`null`
114
+
-`undefined` (or `undef`)
115
+
-`blank` (empty strings)
116
+
-`empty` (empty arrays)
102
117
103
118
### Boolean Operators
104
119
@@ -143,6 +158,7 @@ To store the options, use the constructor below:
143
158
- Set `matchChildKeysAsValues: false` (default) unless you specifically need to match object keys as values.
144
159
- Use `excludeKeys` to skip searching in fields that are never relevant to your searches.
145
160
- For repeated searches with the same options, create a `SearchEngine` instance instead of using the static method.
161
+
- Limit `maxLevels` if you have deeply nested data to avoid performance issues.
0 commit comments