Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accuracy fixes #70

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/1-full-text-search/4-how-search-works.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Atlas Search uses inverted indexes to support text search queries. An inverted i

## Simple string search

When you do a simple query in your database using a LIKE operator, or a regular expression, the database has to scan every document in the collection to find the matching documents. This is a slow process, and it gets slower as the number of documents in the collection increases.
When you do a simple query in your database using a LIKE operator, or a regular expression, the database has to scan every document in the collection, or record in the Index, to find the matching documents. This is a slow process, and it gets slower as the number of documents in the collection increases.

![Simple String Search](/img/1-full-text-search/3-string-search.gif)

Expand Down
9 changes: 6 additions & 3 deletions docs/2-search/2-search-index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ The first step of building the search index is selecting the configuration metho

Next, you need to select a name and data source for your index. Change the name to **fulltextsearch** and select the database **library** and the collection **books**.

<Screenshot alt="The 'Name & Data Source' step of creating a new search index" src="img/screenshots/2-search/2-search-index/4-search-index-config-name-datasource.png" url="https://cloud.mongodb.com" />
<Screenshot
alt="The 'Name & Data Source' step of creating a new search index"
src="img/screenshots/2-search/2-search-index/4-search-index-config-name-datasource.png"
url="https://cloud.mongodb.com"
/>

The final step allows you to review the index configuration and refine it if needed. You may also see the JSON that was generated from your configuration by clicking **View JSON**.

Expand All @@ -31,7 +35,7 @@ The final step allows you to review the index configuration and refine it if nee
```

:::info
The index is using dynamic field mappings. We didn't configure any explicit (static) mappings between the fields in the documents and the search index. That's why Atlas created dynamic mappings that match the data in the documents to some common field types such as `double`, `string`, `array`, `int`, and `double`.
The index is using dynamic field mappings. We didn't configure any explicit (static) mappings between the fields in the documents and the search index. That's why Atlas created dynamic mappings that match the data in the documents to some common field types such as `string`, `array`, `int`, and `double`.
Dynamic mappings are useful when you're just getting started with Atlas Search or if your schema changes regularly. However, they take up more space compared to static mappings.
:::

Expand All @@ -48,4 +52,3 @@ When your search index's status changes to `Ready`, you'll be able to see more i
<Screenshot alt="The 'Search Indexes' page with the newly created index highlighted" src="img/screenshots/2-search/2-search-index/6-search-indexes-list.png" url="https://cloud.mongodb.com" />

Once your new index's status is `Ready`, you can move to the next step.

4 changes: 3 additions & 1 deletion docs/4-add-to-app/1-add-to-app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public async searchBooks(query: string): Promise<Book[]> {
return books;
}
```
While this code works to a certain extent, it is less than optimal. As the dataset grows, the performance of this query will degrade because it will have to scan the entire collection. You cannot query the index with a regular expression. Furthermore, the query only matches on the title and only for the exact sequence of characters.

While this code works to a certain extent, it is less than optimal. As the dataset grows, the performance of this query will degrade because it will have to scan the entire Index. If you query the index with a regular expression, it will need to scan each entry. Furthermore, the query only matches on the title and only for the exact sequence of characters.

Change this code to use the search index instead. You will need to use the `$search` stage in the aggregation pipeline. Have your search cover the title, the author name, and the genres array.

Expand All @@ -53,6 +54,7 @@ public async searchBooks(query: string): Promise<Book[]> {
return books;
}
```

</div>
</details>

Expand Down