Skip to content

Commit 954305f

Browse files
committed
Add FTS query details
1 parent c176140 commit 954305f

8 files changed

+183
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
In C#, you can query a FTS property using either LINQ or RQL.
2+
3+
To query with LINQ, use :dotnet-sdk:`QueryMethods.FullTextSearch
4+
<reference/Realms.QueryMethods.html#Realms_QueryMethods_FullTextSearch_System_String_System_String_>`.
5+
The following examples query the ``Person.Biography`` field.
6+
7+
.. literalinclude:: /examples/generated/dotnet/Indexing.snippet.linq-query-fts.cs
8+
:language: csharp
9+
10+
To query with RQL, use the ``TEXT`` operator. The following example
11+
queries the ``Person.Biography`` field.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
For more information on features of the FTS index, see the API reference for
2+
`RealmIndexType <https://pub.dev/documentation/realm_common/latest/realm_common/RealmIndexType.html>`__.
3+
4+
In the following example, we query on the ``Rug.pattern`` and ``Rug.material``
5+
fields.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The selected language does not support Full-Text Search. You cannot currently
2+
model or query a FTS property in this language.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
To query an FTS indexed property, use the ``TEXT`` predicate in your
2+
:js-sdk:`filtered <classes/Results.html#filtered>` query.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
In the following example, the ``Frog`` object type has an FTS index property
2+
called ``physicalDescription`` that we can filter by to find different types
3+
of frogs.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
To query an FTS indexed property, use the ``TEXT`` predicate in your
2+
:js-sdk:`filtered <classes/Results.html#filtered>` query.
3+
4+
In the following example, we query on the ``Book.name`` field using the
5+
following ``Book`` object model.
6+
7+
.. literalinclude:: /examples/generated/node/v12/full-text-search.test.snippet.node-fts-annotation.ts
8+
:language: typescript
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: cpp-sdk
5+
content: |
6+
7+
.. literalinclude:: /examples/MissingPlaceholders/api.cpp
8+
:language: cpp
9+
:copyable: false
10+
11+
- id: csharp
12+
content: |
13+
14+
.. literalinclude:: /examples/generated/dotnet/Indexing.snippet.rql-query-fts.cs
15+
:language: csharp
16+
:copyable: false
17+
18+
- id: dart
19+
content: |
20+
21+
.. literalinclude:: /examples/generated/flutter/full_text_search_test.snippet.flutter-fts-query.dart
22+
:language: dart
23+
24+
- id: java
25+
content: |
26+
27+
.. literalinclude:: /examples/MissingPlaceholders/api.java
28+
:language: java
29+
:copyable: false
30+
31+
- id: java-kotlin
32+
content: |
33+
34+
.. literalinclude:: /examples/MissingPlaceholders/api-java-kotlin.kt
35+
:language: kotlin
36+
:copyable: false
37+
38+
- id: javascript
39+
content: |
40+
41+
.. literalinclude:: /examples/MissingPlaceholders/example.js
42+
:language: javascript
43+
:copyable: false
44+
45+
- id: kotlin
46+
content: |
47+
48+
.. literalinclude:: /examples/generated/kotlin/ReadTest.snippet.query-fts-property.kt
49+
:language: kotlin
50+
51+
- id: objectivec
52+
content: |
53+
54+
.. literalinclude:: /examples/MissingPlaceholders/api.m
55+
:language: objectivec
56+
:copyable: false
57+
58+
- id: swift
59+
content: |
60+
61+
.. literalinclude:: /examples/MissingPlaceholders/api.swift
62+
:language: swift
63+
:copyable: false
64+
65+
- id: typescript
66+
content: |
67+
68+
.. literalinclude:: /examples/generated/node/v12/full-text-search.test.snippet.node-fts-query.ts
69+
:language: typescript

source/sdk/crud/read.txt

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,8 +1727,89 @@ name that's persisted in the database.
17271727

17281728
.. _sdks-read-filter-by-fts:
17291729

1730-
Filter by Full-Text Search Property
1731-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1730+
Filter a Full-Text Search Property
1731+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1732+
1733+
If your data model includes a :ref:`Full-Text Search (FTS) <sdks-fts-property>`
1734+
index property, you can filter by the property using the ``TEXT`` predicate.
1735+
Words in the query are converted to tokens by a tokenizer using the following
1736+
rules:
1737+
1738+
- Tokens can only consist of characters from ASCII and the Latin-1
1739+
supplement (western languages). All other characters are considered whitespace.
1740+
- Words split by a hyphen (``-``) are split into two tokens. For example,
1741+
``full-text`` splits into ``full`` and ``text``.
1742+
- Tokens are diacritics- and case-insensitive.
1743+
1744+
You can search for an entire word or phrase, or limit your results with the
1745+
following characters:
1746+
1747+
- Exclude results for a word by placing the ``-`` character in front of the
1748+
word. For example, ``fiction -science`` would include all search results
1749+
for ``fiction`` and exclude those that include the word ``science``.
1750+
- Specify prefixes by placing the ``*`` character at the end of a word. For
1751+
example, ``fict*`` would include all search results for ``fiction`` and
1752+
``fictitious``. The SDK does *not* currently support suffix searches.
1753+
1754+
The SDK returns a Boolean match for the specified query, instead of a
1755+
relevance-based match.
1756+
1757+
In the following example, the ``Frog`` object type has an FTS index property
1758+
called ``physicalDescription`` that we can filter by to find different types of frogs:
1759+
1760+
.. tabs-drivers::
1761+
1762+
.. tab::
1763+
:tabid: cpp-sdk
1764+
1765+
.. include:: /includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst
1766+
1767+
.. tab::
1768+
:tabid: csharp
1769+
1770+
.. include:: /includes/api-details/csharp/crud/read-filter-full-text-search-property-description.rst
1771+
1772+
.. tab::
1773+
:tabid: dart
1774+
1775+
.. include:: /includes/api-details/dart/crud/read-filter-full-text-search-property-description.rst
1776+
1777+
.. tab::
1778+
:tabid: java
1779+
1780+
.. include:: /includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst
1781+
1782+
.. tab::
1783+
:tabid: java-kotlin
1784+
1785+
.. include:: /includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst
1786+
1787+
.. tab::
1788+
:tabid: javascript
1789+
1790+
.. include:: /includes/api-details/javascript/crud/read-filter-full-text-search-property-description.rst
1791+
1792+
.. tab::
1793+
:tabid: kotlin
1794+
1795+
.. include:: /includes/api-details/kotlin/crud/read-filter-full-text-search-property-description.rst
1796+
1797+
.. tab::
1798+
:tabid: objectivec
1799+
1800+
.. include:: /includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst
1801+
1802+
.. tab::
1803+
:tabid: swift
1804+
1805+
.. include:: /includes/api-details/generic/crud/read-filter-full-text-search-property-not-supported.rst
1806+
1807+
.. tab::
1808+
:tabid: typescript
1809+
1810+
.. include:: /includes/api-details/typescript/crud/read-filter-full-text-search-property-description.rst
1811+
1812+
.. include:: /includes/sdk-examples/crud/read-filter-full-text-search-property.rst
17321813

17331814
.. _sdks-read-query-relationship-properties:
17341815

0 commit comments

Comments
 (0)