mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-09 05:30:44 +02:00
support highlighting on resolver
This commit is contained in:
@@ -27,14 +27,14 @@ FlexSearch Documents also contain these features:
|
||||
<td>Default</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>document</td>
|
||||
<td><code>document</code></td>
|
||||
<td><a href="#the-document-descriptor">Document Descriptor</a></td>
|
||||
<td>Includes any specific information about how the document data should be indexed</td>
|
||||
<td style="font-style: italic">(mandatory)</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>worker</td>
|
||||
<td><code>worker</code></td>
|
||||
<td>Boolean<br>String</td>
|
||||
<td>Enable a worker distributed model. Read more about here: <a href="worker.md">Worker Index</a></td>
|
||||
<td><code>false</code></td>
|
||||
@@ -43,7 +43,7 @@ FlexSearch Documents also contain these features:
|
||||
|
||||
### Document Search Options
|
||||
|
||||
> Document search options basically inherits from [Index Search Options](../README.md#search-options), so you can apply most of those options either in the top scope of the config (for all fields) or as per field or both of them.
|
||||
> Document search options basically inherit from [Index Search Options](../README.md#search-options), so you can apply most of those options either in the top scope of the config (for all fields) or as per field or both of them.
|
||||
|
||||
<table>
|
||||
<tr></tr>
|
||||
@@ -54,35 +54,45 @@ FlexSearch Documents also contain these features:
|
||||
<td>Default</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>index</td>
|
||||
<td><code>index</code><br><code>field</code></td>
|
||||
<td>String<br>Array<String><br>Array<SearchOptions></td>
|
||||
<td>Sets the <a href="#docs">document fields</a> which should be searched. When no field is set, all fields will be searched. <a href="#options-field-search">Custom options per field</a> are also supported.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>tag</td>
|
||||
<td><code>tag</code></td>
|
||||
<td>Object<field:tag></td>
|
||||
<td>Sets the <a href="#docs">document fields</a> which should be searched. When no field is set, all fields will be searched. <a href="#options-field-search">Custom options per field</a> are also supported.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>enrich</td>
|
||||
<td><code>enrich</code></td>
|
||||
<td>Boolean</td>
|
||||
<td>Enrich IDs from the results with the corresponding documents.</td>
|
||||
<td><code>false</code></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>merge</td>
|
||||
<td><code>highlight</code></td>
|
||||
<td>
|
||||
<a href="./result-highlighting.md#highlighting-options">Highlighting Options</a><br>
|
||||
String
|
||||
</td>
|
||||
<td>Highlight query matches in the result (for Document Indexes only)</td>
|
||||
<td><code>false</code></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td><code>merge</code></td>
|
||||
<td>Boolean</td>
|
||||
<td>Merge multiple fields in resultset into one and group results per ID</td>
|
||||
<td><code>false</code></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>pluck</td>
|
||||
<td><code>pluck</code></td>
|
||||
<td>String</td>
|
||||
<td>Pick and apply search to just one field and return a flat result representation</td>
|
||||
<td><code>false</code></td>
|
||||
@@ -102,28 +112,28 @@ When creating a `Document`-Index you will need to define a document descriptor i
|
||||
<td>Default</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>id</td>
|
||||
<td><code>id</code></td>
|
||||
<td>String</td>
|
||||
<td vertical-align="top"></td>
|
||||
<td></td>
|
||||
<td><code>"id"</code></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>index</td>
|
||||
<td><code>index</code></td>
|
||||
<td>String<br>Array<String><br>Array<FieldOptions></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>tag</td>
|
||||
<td><code>tag</code></td>
|
||||
<td>String<br>Array<String><br>Array<FieldOptions></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>store</td>
|
||||
<td><code>store</code></td>
|
||||
<td>Boolean<br>String<br>Array<String><br>Array<FieldOptions></td>
|
||||
<td></td>
|
||||
<td><code>false</code></td>
|
||||
@@ -143,21 +153,21 @@ When creating a `Document`-Index you will need to define a document descriptor i
|
||||
<td>Default</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>field</td>
|
||||
<td><code>field</code></td>
|
||||
<td>String</td>
|
||||
<td>The field name (colon seperated syntax)</td>
|
||||
<td style="font-style: italic">(mandatory)</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>filter</td>
|
||||
<td><code>filter</code></td>
|
||||
<td>Function</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>custom</td>
|
||||
<td><code>custom</code></td>
|
||||
<td>Function</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
185
doc/resolver.md
185
doc/resolver.md
@@ -147,6 +147,191 @@ const result = new Resolver({
|
||||
.resolve(100);
|
||||
```
|
||||
|
||||
## Resolver Tasks
|
||||
|
||||
<table>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>Method</td>
|
||||
<td>Description</td>
|
||||
<td>Return</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>.and(options,...)</code><br>
|
||||
<code>.or(options,...)</code><br>
|
||||
<code>.not(options,...)</code><br>
|
||||
<code>.xor(options,...)</code>
|
||||
</td>
|
||||
<td>Apply an operation</td>
|
||||
<td>Returns a <code>Resolver</code> when <code>resolve</code> was not set to <code>false</code> within the options, otherwise it returns the result (or promise in async context).</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>.limit(number)</code><br>
|
||||
<code>.offset(number)</code><br>
|
||||
<code>.boost(number)</code>
|
||||
</td>
|
||||
<td>Apply boost, limit and offset to the result</td>
|
||||
<td>Returns a <code>Resolver</code></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>.resolve(options)</code>
|
||||
</td>
|
||||
<td>Resolve results</td>
|
||||
<td>Returns the final result or promise in async context (can't be executed twice)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## Resolver Options
|
||||
|
||||
<table>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>Option</td>
|
||||
<td>Values</td>
|
||||
<td>Description</td>
|
||||
<td>Default</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td colspan="4">Resolver Task Options:</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>query</code></td>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>The search query</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td><code>index</code></td>
|
||||
<td>
|
||||
<code>Index</code><br>
|
||||
<code>Document</code>
|
||||
</td>
|
||||
<td>Assign the index where the query should be applied to</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td><code>suggest</code></td>
|
||||
<td>
|
||||
Boolean
|
||||
</td>
|
||||
<td>Enables <a href="../README.md#suggestions">suggestions</a> in results</td>
|
||||
<td>false</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td><code>boost</code></td>
|
||||
<td>
|
||||
Number
|
||||
</td>
|
||||
<td>Boost or reduce the score of this query</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td><code>async</code></td>
|
||||
<td>
|
||||
Boolean
|
||||
</td>
|
||||
<td>Use a <a href="#using-async-queries-incl-runtime-balancer">parallel processing workflow</a></td>
|
||||
<td>false</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td><code>queue</code></td>
|
||||
<td>
|
||||
Boolean
|
||||
</td>
|
||||
<td>Use a <a href="#queuing-async-queries">queued processing workflow</a></td>
|
||||
<td>false</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>and</code><br>
|
||||
<code>or</code><br>
|
||||
<code>not</code><br>
|
||||
<code>xor</code><br>
|
||||
</td>
|
||||
<td>
|
||||
Array<<a href="#resolver-options">ResolverOptions</a>>
|
||||
</td>
|
||||
<td>Apply nested queries</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td><code>resolve</code></td>
|
||||
<td>
|
||||
Boolean
|
||||
</td>
|
||||
<td>
|
||||
Resolve the result immediately or not. When set to <code>true</code> all final resolve options are also allowed and there can't exist any further resolver operations.
|
||||
</td>
|
||||
<td>false</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">Document Resolver Options:</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>field</code><br><code>pluck</code></td>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>Select the Document field on which the query should apply to.</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">Final Resolve Options:</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>enrich</code></td>
|
||||
<td>
|
||||
Boolean
|
||||
</td>
|
||||
<td>Enrich IDs from the results with the corresponding documents (for Document Indexes only)</td>
|
||||
<td>true</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td><code>highlight</code></td>
|
||||
<td>
|
||||
<a href="./result-highlighting.md#highlighting-options">Highlighting Options</a><br>
|
||||
String
|
||||
</td>
|
||||
<td>Highlight query matches in the result (for Document Indexes only)</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td><code>limit</code></td>
|
||||
<td>
|
||||
Number
|
||||
</td>
|
||||
<td>Sets the limit of results</td>
|
||||
<td>100</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td><code>offset</code></td>
|
||||
<td>
|
||||
Boolean
|
||||
</td>
|
||||
<td>Apply offset (skip items)</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### Using Cached Queries
|
||||
|
||||
```js
|
||||
|
Reference in New Issue
Block a user