mirror of
https://github.com/supabase/supabase.git
synced 2026-06-02 02:43:26 +08:00
147 lines
2.5 KiB
Plaintext
147 lines
2.5 KiB
Plaintext
---
|
|
id: textsearch
|
|
title: ".textSearch()"
|
|
slug: textsearch
|
|
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/dart.yml
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabsPanel from '@theme/TabsPanel';
|
|
|
|
Finds all rows whose tsvector value on the stated `column` matches to_tsquery(query).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
### Text search
|
|
|
|
|
|
|
|
<Tabs
|
|
defaultActiveId="dart"
|
|
groupId="reference/dart"
|
|
values={[{ label: 'Dart', value: 'dart' }]}>
|
|
|
|
<TabsPanel id="dart" label="dart">
|
|
|
|
```dart
|
|
final res = await supabase
|
|
.from('quotes')
|
|
.select('catchphrase')
|
|
.textSearch('catchphrase', "'fat' & 'cat'",
|
|
config: 'english'
|
|
)
|
|
.execute();
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
### Basic normalization
|
|
|
|
Uses PostgreSQL's `plainto_tsquery` function.
|
|
|
|
<Tabs
|
|
defaultActiveId="dart"
|
|
groupId="reference/dart"
|
|
values={[{ label: 'Dart', value: 'dart' }]}>
|
|
|
|
<TabsPanel id="dart" label="dart">
|
|
|
|
```dart
|
|
final res = await supabase
|
|
.from('quotes')
|
|
.select('catchphrase')
|
|
.textSearch('catchphrase', "'fat' & 'cat'",
|
|
type: TextSearchType.plain,
|
|
config: 'english'
|
|
)
|
|
.execute();
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
### Full normalization
|
|
|
|
Uses PostgreSQL's `phraseto_tsquery` function.
|
|
|
|
<Tabs
|
|
defaultActiveId="dart"
|
|
groupId="reference/dart"
|
|
values={[{ label: 'Dart', value: 'dart' }]}>
|
|
|
|
<TabsPanel id="dart" label="dart">
|
|
|
|
```dart
|
|
final res = await supabase
|
|
.from('quotes')
|
|
.select('catchphrase')
|
|
.textSearch('catchphrase', "'fat' & 'cat'",
|
|
type: TextSearchType.phrase,
|
|
config: 'english'
|
|
)
|
|
.execute();
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
### Full normalization
|
|
|
|
Uses PostgreSQL's `websearch_to_tsquery` function.
|
|
This function will never raise syntax errors, which makes it possible to use raw user-supplied input for search, and can be used
|
|
with advanced operators.
|
|
|
|
- `unquoted text`: text not inside quote marks will be converted to terms separated by & operators, as if processed by plainto_tsquery.
|
|
- `"quoted text"`: text inside quote marks will be converted to terms separated by <-> operators, as if processed by phraseto_tsquery.
|
|
- `OR`: the word “or” will be converted to the | operator.
|
|
- `-`: a dash will be converted to the ! operator.
|
|
|
|
|
|
<Tabs
|
|
defaultActiveId="dart"
|
|
groupId="reference/dart"
|
|
values={[{ label: 'Dart', value: 'dart' }]}>
|
|
|
|
<TabsPanel id="dart" label="dart">
|
|
|
|
```dart
|
|
final res = await supabase
|
|
.from('quotes')
|
|
.select('catchphrase')
|
|
.textSearch('catchphrase', "'fat or cat'",
|
|
type: TextSearchType.websearch,
|
|
config: 'english'
|
|
)
|
|
.execute();
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs> |