Skip to content

Commit

Permalink
v0.6.0 Pagination, Fix: #48
Browse files Browse the repository at this point in the history
  • Loading branch information
ts-thomas committed Feb 19, 2019
1 parent 78fbae7 commit f9e2768
Show file tree
Hide file tree
Showing 10 changed files with 832 additions and 352 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

#### v0.6.0

- Pagination

#### v0.5.3

- Logical Operator
Expand Down
153 changes: 139 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ All Features:
<tr></tr>
<tr>
<td>
<a href="#webworker">Web-Worker Sharding</a> (not available in Node.js)
<a href="#webworker">Web-Workers</a> (not available in Node.js)
</td>
<td>✔</td>
<td>-</td>
Expand All @@ -121,6 +121,15 @@ All Features:
<td>-</td>
</tr>
<tr></tr>
<tr>
<td>
<a href="#operators">Logical Operators</a>
</td>
<td>✔</td>
<td>✔</td>
<td>-</td>
</tr>
<tr></tr>
<tr>
<td>
<a href="#where">Where / Find</a> / <a href="#tags">Tags</a>
Expand All @@ -132,7 +141,7 @@ All Features:
<tr></tr>
<tr>
<td>
Partial Matching
<a href="#tokenizer">Partial Matching</a>
</td>
<td>✔</td>
<td>✔</td>
Expand All @@ -141,7 +150,7 @@ All Features:
<tr></tr>
<tr>
<td>
Multi-Phrase Search
Relevance Scoring
</td>
<td>✔</td>
<td>✔</td>
Expand All @@ -150,16 +159,16 @@ All Features:
<tr></tr>
<tr>
<td>
Relevance-based Scoring
<a href="#cache">Auto-Balanced Cache by Popularity</a>
</td>
<td>✔</td>
<td></td>
<td></td>
<td>-</td>
<td>-</td>
</tr>
<tr></tr>
<tr>
<td>
<a href="#cache">Auto-Balanced Cache by Popularity</a>
<a href="#pagination">Pagination</a>
</td>
<td>✔</td>
<td>-</td>
Expand All @@ -168,7 +177,7 @@ All Features:
<tr></tr>
<tr>
<td>
Suggestions (Results)
<a href="#suggestions">Suggestions</a>
</td>
<td>✔</td>
<td>-</td>
Expand Down Expand Up @@ -597,6 +606,8 @@ Index methods:
- <a href="#index.encode">Index.__encode__(string)</a>
- <a href="#index.export">Index.__export__()</a>
- <a href="#index.import">Index.__import__(string)</a>
- <a href="#index.length">Index.__length__()</a>
- <a href="#index.index">Index.__index__()</a>

## Usage

Expand Down Expand Up @@ -740,13 +751,56 @@ index.search("John", {
});
```

<a name="pagination"></a>
#### Pagination

FlexSearch is providing a cursor-based pagination which has the ability to inject into the most-inner process. This enables a lot of possible performance improvements.

> The cursor implementation may be changed often. Just take the cursor as it is and do not expect any specific value or format.
To enable pagination you have to pass a ___page___ field within the custom search object (optionally also a ___limit___ as maximum items per page).

Get the first page of results:
```js
var response = index.search("John Doe", {

limit: 5,
page: true
});
```

Always when passing a ___page___ within custom search the ___response___ have this format:
```json
{
"page": "xxx:xxx",
"next": "xxx:xxx",
"result": []
}
```

- ___page___ is the pointer to the current page
- ___next___ is the pointer to the next page or ___null___ when no pages are left
- ___result___ yields the searching results

Get the second (next) page of results:
```js
index.search("John Doe", {

limit: 10,
page: response.next
});
```

The limit can be modified for each query.

<a name="suggestions"></a>
#### Suggestions

Get also suggestions for a query:

```js
index.search({

query: "John Doe",
suggest: true
});
Expand Down Expand Up @@ -809,6 +863,28 @@ index.init({

> Re-initialization will also destroy the old index.
<a name="index.length"></a>
#### Get Length

Get the length of an index:

```js
var length = index.length;
```

<a name="index.index"></a>
#### Get Register

Get the index (register) of an instance:

```js
var index = index.index;
```

The register has the format _"@" + id_.

> Important: Do not modify manually, just use it as read-only.
<a name="flexsearch.addmatcher"></a>
#### Add custom matcher

Expand Down Expand Up @@ -1275,7 +1351,7 @@ var results = index.search("foobar", {

Search the same query on multiple fields:

> Using ___bool___ as a logical operator when searching through multiple fields. The default operator when not set is ___"and"___. It is planned to extend the concept of logical operators to make combinations of ___and___ / ___or___ / ___not___.
> Using ___bool___ as a logical operator when searching through multiple fields. The default operator when not set is ___"or"___.
```js
var results = index.search({
Expand Down Expand Up @@ -1322,6 +1398,30 @@ var results = index.search([{
```
-->

<a name="operators"></a>
## Logical Operators

There are 3 different operators (and, or, not). Just pass the field ___bool___ in custom search:
```js
var results = index.search([{
field: "title",
query: "foobar",
bool: "and"
},{
field: "body",
query: "content",
bool: "or"
},{
field: "blacklist",
query: "xxx",
bool: "not"
}]);
```

- ___"and"___ indicates to be __required__ in the result
- ___"or"___ indicates to be __optional__ in the result
- ___"not"___ indicates to be __prohibited__ in the result

<a name="where"></a>
## Find / Where

Expand Down Expand Up @@ -2466,12 +2566,12 @@ node compile SUPPORT_WORKER=true
</tr>
<tr></tr>
<tr>
<td>SUPPORT_ENCODER (built-in encoders)</td>
<td>SUPPORT_ENCODER</td>
<td>true, false</td>
</tr>
<tr></tr>
<tr>
<td>SUPPORT_DOCUMENTS</td>
<td>SUPPORT_DOCUMENT</td>
<td>true, false</td>
</tr>
<tr></tr>
Expand All @@ -2496,16 +2596,41 @@ node compile SUPPORT_WORKER=true
</tr>
<tr></tr>
<tr>
<td>SUPPORT_PRESETS</td>
<td>SUPPORT_PRESET</td>
<td>true, false</td>
</tr>
<tr></tr>
<tr>
<td>SUPPORT_INFO</td>
<td>true, false</td>
</tr>
<tr></tr>
<tr>
<td>SUPPORT_SERIALIZE</td>
<td>true, false</td>
</tr>
<tr></tr>
<tr>
<td>SUPPORT_SUGGESTION</td>
<td>true, false</td>
</tr>
<tr></tr>
<tr>
<td>SUPPORT_PAGINATION</td>
<td>true, false</td>
</tr>
<tr></tr>
<tr>
<td>SUPPORT_OPERATOR</td>
<td>true, false</td>
</tr>
<tr></tr>
<tr>
<td>SUPPORT_CALLBACK</td>
<td>true, false</td>
</tr>
<tr>
<td><br><b>Language Flags </b>(includes stemmer and filter)</td>
<td><br><b>Language Packs</b></td>
<td></td>
</tr>
<tr>
Expand Down
Loading

0 comments on commit f9e2768

Please sign in to comment.