Skip to content

Commit

Permalink
Merge pull request #22 from mongodb-developer/update-test-search-results
Browse files Browse the repository at this point in the history
update test search results
  • Loading branch information
joellord authored Apr 15, 2024
2 parents 9a60313 + 5efae94 commit f3bbbb6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/2-search/3-test-search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ and look at the results you get.
<Screenshot src="img/screenshots/2-search/3-test-search/2-search-tester.png" alt="The Search Tester" url="https://cloud.mongodb.com" />

You can see that you get a list of books back including:
* High-Flavor, Low-Fat Vegetarian _Cooking_
* _Cooking_ Secrets of the CIA: Favorite Recipes from the Culinary Institu…
* Pennsylvania Dutch _Cooking_: A Mennonite Community Cookbook
* Semi-Homemade _Cooking_: Quick, Marvelous Meals and Nothing is Made from…
* Cookin' Cajun _Cooking_ School Cookbook - Creole and Cajun Cuisine from …

All those results match the word _cooking_. Notice how capitalization doesn't matter. Neither does the placement of the word in the title. The search index is smart enough to find the word _cooking_ in all those titles.

Expand Down
34 changes: 16 additions & 18 deletions docs/7-vector-search/9-filtering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,28 @@ In this case, we already have our index and we're going to edit it in the JSON e

```js
{
"mappings": {
"dynamic": true,
"fields": {
"embeddings": {
"dimensions": 384,
"similarity": "cosine",
"type": "knnVector"
},
"language": {
"normalizer": "none",
"type": "token"
}
"fields": [
{
"type": "vector",
"path": "embeddings",
"numDimensions": 1536,
"similarity": "cosine"
},
{
"type": "filter",
"path": "language"
}
}
]
}
```

The only difference is that we've added this part, stating that `language` should be indexed as a [token](https://www.mongodb.com/docs/atlas/atlas-search/field-types/token-type/), not as a string (we're not going to do full text search here, but Vector Search)
The only difference is that we've added this part, stating that `language` should be indexed as a [filter](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-type/#about-the-filter-type).

```js
"language": {
"normalizer": "none",
"type": "token"
}
{
"type": "filter",
"path": "language"
}
```

Add that new aggregation pipeline in your code (`server/src/controllers/books.ts` inside the now familiar `searchBooks` method) and when searching, you'll get semantic results written in Spanish.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f3bbbb6

Please sign in to comment.