Skip to content

Commit 48b298b

Browse files
DOCSP-52186 mongosh examples for custom analyzers (#13637)
* DOCSP-52186 mongosh examples for custom analyzers * Update content/atlas/source/atlas-search/analyzers/character-filters.txt Co-authored-by: davidhou17 <55004296+davidhou17@users.noreply.github.com> --------- Co-authored-by: davidhou17 <55004296+davidhou17@users.noreply.github.com>
1 parent 82877fc commit 48b298b

File tree

148 files changed

+6042
-2799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+6042
-2799
lines changed

content/atlas/source/atlas-search/analyzers/character-filters.txt

Lines changed: 91 additions & 336 deletions
Large diffs are not rendered by default.

content/atlas/source/atlas-search/analyzers/token-filters.txt

Lines changed: 418 additions & 1734 deletions
Large diffs are not rendered by default.

content/atlas/source/atlas-search/analyzers/tokenizers.txt

Lines changed: 298 additions & 728 deletions
Large diffs are not rendered by default.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
db.minutes.createSearchIndex(
2+
"default",
3+
{
4+
"mappings": {
5+
"fields": {
6+
"text": {
7+
"type": "document",
8+
"dynamic": true,
9+
"fields": {
10+
"en_US": {
11+
"analyzer": "htmlStrippingAnalyzer",
12+
"type": "string"
13+
}
14+
}
15+
}
16+
}
17+
},
18+
"analyzers": [
19+
{
20+
"name": "htmlStrippingAnalyzer",
21+
"charFilters": [
22+
{
23+
"type": "htmlStrip",
24+
"ignoredTags": ["a"]
25+
}
26+
],
27+
"tokenizer": {
28+
"type": "standard"
29+
},
30+
"tokenFilters": []
31+
}
32+
]
33+
}
34+
)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.. io-code-block::
2+
:copyable: true
3+
4+
.. input::
5+
:language: json
6+
:linenos:
7+
8+
db.minutes.aggregate([
9+
{
10+
"$search": {
11+
"text": {
12+
"query": "head",
13+
"path": "text.en_US"
14+
}
15+
}
16+
},
17+
{
18+
"$project": {
19+
"_id": 1,
20+
"text.en_US": 1
21+
}
22+
}
23+
])
24+
25+
.. output::
26+
:language: js
27+
:visible: false
28+
29+
[
30+
{
31+
_id: 2,
32+
text: { en_US: "The head of the sales department spoke first." }
33+
},
34+
{
35+
_id: 3,
36+
text: {
37+
en_US: "<body>We'll head out to the conference room by noon.</body>"
38+
}
39+
}
40+
]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
1. Click the :guilabel:`Query` button for your index.
2+
#. Click :guilabel:`Edit Query` to edit the query.
3+
#. Click on the query bar and select the database and collection.
4+
#. Replace the default query with the following and click
5+
:guilabel:`Find`:
6+
7+
.. io-code-block::
8+
:copyable: true
9+
10+
.. input::
11+
:language: json
12+
13+
{
14+
"$search": {
15+
"text": {
16+
"query": "head",
17+
"path": "text.en_US"
18+
}
19+
}
20+
}
21+
22+
.. output::
23+
:language: js
24+
:visible: false
25+
26+
SCORE: 0.32283568382263184 _id: “2”
27+
message: "do not forget to SIGN-IN. See ① for details."
28+
page_updated_by: Object
29+
last_name: "OHRBACH"
30+
first_name: "Noël"
31+
email: "ohrbach@example.com"
32+
phone: "(123) 456 0987"
33+
text: Object
34+
en_US: "The head of the sales department spoke first."
35+
fa_IR: "ابتدا رئیس بخش فروش صحبت کرد"
36+
sv_FI: "Först talade chefen för försäljningsavdelningen"
37+
38+
SCORE: 0.3076632022857666 _id: “3”
39+
message: "try to sign-in"
40+
page_updated_by: Object
41+
last_name: "LEWINSKY"
42+
first_name: "Brièle"
43+
email: "lewinsky@example.com"
44+
phone: "(123).456.9870"
45+
text: Object
46+
en_US: "<body>We'll head out to the conference room by noon.</body>"
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.. tabs::
2+
3+
.. tab:: Visual Editor
4+
:tabid: vib
5+
6+
.. |analyzer-name| replace:: ``htmlStrippingAnalyzer``
7+
.. |fts-char-filter| replace:: :guilabel:`htmlStrip`
8+
.. |fts-char-filter-option-name| replace:: :guilabel:`ignoredTags`
9+
.. |fts-char-filter-option-value| replace:: ``a``
10+
.. |fts-tokenizer| replace:: :guilabel:`standard`
11+
.. |minutes-collection-field| replace:: **text.en_US** nested
12+
.. |fts-field-type| replace:: **String**
13+
14+
.. include:: /includes/fts/extracts/fts-char-filter-htmlstrip-config.rst
15+
16+
.. tab:: JSON Editor
17+
:tabid: jsoneditor
18+
19+
Replace the default index definition with the following:
20+
21+
.. code-block:: json
22+
:copyable: true
23+
:linenos:
24+
25+
{
26+
"mappings": {
27+
"fields": {
28+
"text": {
29+
"type": "document",
30+
"dynamic": true,
31+
"fields": {
32+
"en_US": {
33+
"analyzer": "htmlStrippingAnalyzer",
34+
"type": "string"
35+
}
36+
}
37+
}
38+
}
39+
},
40+
"analyzers": [{
41+
"name": "htmlStrippingAnalyzer",
42+
"charFilters": [{
43+
"type": "htmlStrip",
44+
"ignoredTags": ["a"]
45+
}],
46+
"tokenizer": {
47+
"type": "standard"
48+
},
49+
"tokenFilters": []
50+
}]
51+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
db.minutes.createSearchIndex("default", {
2+
"mappings": {
3+
"fields": {
4+
"message": {
5+
"type": "string",
6+
"analyzer": "normalizingAnalyzer"
7+
}
8+
}
9+
},
10+
"analyzers": [
11+
{
12+
"name": "normalizingAnalyzer",
13+
"charFilters": [
14+
{
15+
"type": "icuNormalize"
16+
}
17+
],
18+
"tokenizer": {
19+
"type": "whitespace"
20+
},
21+
"tokenFilters": []
22+
}
23+
]
24+
})
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. io-code-block::
2+
:copyable: true
3+
4+
.. input::
5+
:language: json
6+
:linenos:
7+
8+
db.minutes.aggregate([
9+
{
10+
"$search": {
11+
"text": {
12+
"query": "no",
13+
"path": "message"
14+
}
15+
}
16+
},
17+
{
18+
"$project": {
19+
"_id": 1,
20+
"message": 1,
21+
"title": 1
22+
}
23+
}
24+
])
25+
26+
.. output::
27+
:language: js
28+
:visible: false
29+
30+
[
31+
{
32+
_id: 4,
33+
title: 'The daily huddle on tHe StandUpApp2',
34+
message: 'write down your signature or phone №'
35+
}
36+
]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
1. Click the :guilabel:`Query` button for your index.
2+
#. Click :guilabel:`Edit Query` to edit the query.
3+
#. Click on the query bar and select the database and collection.
4+
#. Replace the default query with the following and click
5+
:guilabel:`Find`:
6+
7+
.. io-code-block::
8+
:copyable: true
9+
10+
.. input::
11+
:language: json
12+
13+
{
14+
"$search": {
15+
"text": {
16+
"query": "no",
17+
"path": "message"
18+
}
19+
}
20+
}
21+
22+
.. output::
23+
:language: js
24+
:visible: false
25+
26+
SCORE: 0.4923309087753296 _id: “4”
27+
message: "write down your signature or phone №"
28+
page_updated_by: Object
29+
last_name: "LEVINSKI"
30+
first_name: "François"
31+
email: "levinski@example.com"
32+
phone: "123-456-8907"
33+
text: Object
34+
en_US: "<body>This page has been updated with the items on the agenda.</body>"
35+
es_MX: "La página ha sido actualizada con los puntos de la agenda."
36+
pl_PL: "Strona została zaktualizowana o punkty porządku obrad."

0 commit comments

Comments
 (0)