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
+67-1Lines changed: 67 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,72 @@ To delete a record from the search engine:
96
96
searchEngine.DeleteRecord(1);
97
97
```
98
98
99
+
### Pagination
100
+
101
+
In addition to basic searching, you can easily implement pagination using the `skip` and `limit` parameters in the `Search` method. This is especially useful when dealing with large datasets where you only want to display a subset of the results at a time.
102
+
103
+
```csharp
104
+
varresultsPage1=searchEngine.Search(
105
+
search: "quick fox",
106
+
respectTokenOrder: true,
107
+
skip: 0, // Skip 0 records, start from the beginning
108
+
limit: 10// Limit to 10 records in this page
109
+
);
110
+
111
+
varresultsPage2=searchEngine.Search(
112
+
search: "quick fox",
113
+
respectTokenOrder: true,
114
+
skip: 10, // Skip the first 10 records
115
+
limit: 10// Limit to 10 records in this page
116
+
);
117
+
```
118
+
119
+
### Adding Facets
120
+
121
+
To associate a facet (e.g., category, author) with a record:
122
+
123
+
```csharp
124
+
searchEngine.AddFacet(1, "category", "books");
125
+
searchEngine.AddFacet(1, "author", "John Doe");
126
+
```
127
+
128
+
### Deleting Facets
129
+
130
+
To remove a specific facet associated with a record:
When you're done using the search engine, ensure proper cleanup:
@@ -259,7 +325,7 @@ Future Search Engines: Additional search engines, such as Phrase Search Engine a
259
325
260
326
## License
261
327
262
-
ZoneTree.FullTextSearch is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
328
+
ZoneTree.FullTextSearch is licensed under the MIT License. See the [LICENSE](https://github.com/koculu/ZoneTree.FullTextSearch/blob/main/LICENSE) file for more details.
/// Deletes a record from the index without using the secondary index.
232
264
/// </summary>
@@ -291,31 +323,61 @@ public long DeleteRecord(TRecord record)
291
323
}
292
324
293
325
/// <summary>
294
-
/// Searches for records that match the provided tokens, with optional parameters for token order,
295
-
/// skipping records, and limiting the number of results.
326
+
/// Searches the index for records that match the specified tokens, with optional support for facets, token order respect, and pagination.
296
327
/// </summary>
297
-
/// <param name="tokens">The tokens to search for.</param>
298
-
/// <param name="firstLookAt">An optional token to prioritize during the search.</param>
299
-
/// <param name="respectTokenOrder">Indicates whether the order of tokens should be respected during the search.</param>
300
-
/// <param name="skip">The number of records to skip in the result set.</param>
301
-
/// <param name="limit">The maximum number of records to return.</param>
302
-
/// <returns>An array of records that match the search criteria.</returns>
328
+
/// <param name="tokens">
329
+
/// A read-only span of tokens that the records must contain. This parameter is mandatory unless facets are provided.
330
+
/// The tokens are logically grouped using "AND", meaning all tokens must be present in the matching records.
331
+
/// If both the tokens span and the facets span are empty, the result will be an empty array, as searching without tokens and facets is not supported.
332
+
/// Tokens can be empty if facets are provided; in this case, the search will be based solely on the facets.
333
+
/// To retrieve records without specific search tokens or facets, consider fetching them from the actual record source instead of using the search index.
334
+
/// </param>
335
+
/// <param name="firstLookAt">
336
+
/// An optional token that the search will prioritize when searching.
337
+
/// If not specified, the first token in the tokens span is used.
338
+
/// </param>
339
+
/// <param name="respectTokenOrder">
340
+
/// A boolean indicating whether the search should respect the order of tokens in the record.
341
+
/// If true, the records must contain the tokens in the specified order.
342
+
/// </param>
343
+
/// <param name="facets">
344
+
/// An optional read-only span of tokens that can be used to filter the search results.
345
+
/// If any facets are provided, records must contain at least one of these facet tokens to be included in the results.
346
+
/// If the span is empty or not provided, no facet filtering is applied, and all matching records are returned regardless of facet values.
347
+
/// </param>
348
+
/// <param name="skip">
349
+
/// The number of matching records to skip in the result set, useful for pagination.
350
+
/// Defaults to 0.
351
+
/// </param>
352
+
/// <param name="limit">
353
+
/// The maximum number of records to return, useful for limiting the result set size.
354
+
/// Defaults to 0, which indicates no limit.
355
+
/// </param>
356
+
/// <returns>
357
+
/// An array of records that match the specified tokens and facets, respecting the token order if specified.
358
+
/// The array may be empty if no matching records are found.
0 commit comments