You are on page 1of 58

WELCOME

Atlas Search
Hands-on Workshop

Oumayma Abida
Solutions Architect

Paolo Picello
Solutions Architect
AUDIENCE

Who
benefits?
This workshop is designed for
developers, with previous knowledge of
setting up MongoDB environments and
interest in search functionality to make
their data even more accessible.
The following hardware and installations are
required to complete this workshop
A local computer with internet connection and
a modern browser and IDE

A frontend application will be hosted on


StackBlitz and GitHub and ready for you
to fork.

Pre-
requisites
Agenda
Learning the concepts - What is Atlas
Search?

Preparing our Atlas Environment and data

Quiz

Setup Atlas Search

Creating our Realm Application


Agenda
Enabling authentication and expose data

Creating relationships between collections in


Realm

Generating a GraphQL schema

Creating our custom resolvers

Testing our application


Housekeeping
Items
If you have any questions
or issues throughout the Workshop, please
raise your virtual hand ✋

7
Step 1: Click “Reactions “ on the bottom of your screen

Step 2: Click the ✋Raise Hand button

8
Once your hand is raised,
one of the team will send
you a 1:1 chat to assist.

9
Everyone please
raise your hand ✋ now so
we can proceed!

10
What is Search?
What is Search ?

Search, or “Full-Text Search” is the ability to search across all of your data and efficiently return a list of
results, ranked based on how well they matched to the search term

Usually defined as a Search bar …

Not an exact match, but a LIST OF RESULTS BASED ON RELEVANCE

Result 1

Result 2
Results based on a score
Result 3

Result 4
Database vs Search Engine
Database vs Search Engine
Database Search Engine

Queries don’t ask for a specific piece of


Queries ask for exact matches to a specific data. You ask the system to look through all
condition then perform an operation (CRUD) of its contents and return what it thinks is the
most relevant to your query or search term

What is user_ID 4810’s account balance ? “What was that movie where Harrison Ford plays
an archaeologist?”

Database returns a specific record of data Search Engine returns a list of results
(exact match on user_ID 4810) based on relevance
What is Atlas
Search?
How developers do it today ?
How do developers do it today?
They need to combine different technologies to make it work

Database Search Engine

Search Engine with queries which are much


Transactional database with identified
more free form; all possible user interactions
common queries
and queries cannot be assumed upfront

CRUD Fuzzy Search

Change Streams Highlighting

Aggregations Check my account balance Facets

Different types of indexes View my purchase history Synonyms

ACID Transactions View my wish list Scoring / Weighting

… …
How developers do it today ?
Historically, Search has been a real pain to implement

Database Search Engine

3 different technologies

Different query languages

Different data models


ETL
Extract, Transform, Load
Data duplication

No Real-time

No strong consistency

Data stored and queried in an Data stored and queried in an


optimized way for transactions optimized way for Search
How we do it better
What did we build ?
BEFORE AFTER

Transactional DB Search Engine MongoDB Atlas node

ETL One technology


Extract, Transform, Load
One query language

One infrastructure

No data duplication

Search
Cost reduction

CRUD
MQL Same API / Connection String

Application

No ETL Required

Fully Managed
Atlas Search Architecture
MongoDB Atlas Node

Java Web Process

Initial Sync & Change Streams


Configure indexes

API API
MongoDB Atlas
mongod ObjectID + Search metadata Automation
Lucene

List of documents Contains only the Search Indexes +


following the lucene order ObjectIDs
$search

Search query results

Mongo Shell
Search index configuration

$search Atlas UI, API, Terraform MongoDB Atlas


Compass

Drivers
Search features available with
MongoDB Atlas Search
Analyzers

We start with an original query


Lions and tigers and bears, oh my!

Analyzers apply parsing and


language rules to the query L lions and tigers and bears, oh my!

Tokens are the individual terms that lions tigers bears oh my


are queried; think of these as the
words that matter in a search query
Analyzers

Analyzers also support language


rules

A search for... “shard”

...can return results for related


words [“shard”, “shards”, “sharded”,
“sharding”, ...]
Other supported search features
Search features are all about helping customers make their data more discoverable
and relevant for end users

● Support for 40+ languages

● Autocomplete

● Highlighting

● Fuzzy matching (typo tolerance)

● Faceting

● Multiple data types

● Synonyms Each language analyzer has built-in rules based on the language’s usage pattern

● Scoring
Other supported search features
Search features are all about helping customers make their data more discoverable
and relevant for end users

● Support for 30+ languages

● Autocomplete

● Highlighting

● Fuzzy matching (typo tolerance)

● Faceting

● Multiple data types

● Synonyms

● Scoring
Other supported search features
Search features are all about helping customers make their data more discoverable
and relevant for end users

● Support for 30+ languages

● Autocomplete

● Highlighting

● Fuzzy matching (typo tolerance)

● Faceting

● Multiple data types

● Synonyms

● Scoring
Other supported search features
Search features are all about helping customers make their data more discoverable
and relevant for end users

● Support for 30+ languages

● Autocomplete

● Highlighting

● Fuzzy matching (typo tolerance)

● Faceting

● Multiple data types

● Synonyms

● Scoring
Other supported search features
Search features are all about helping customers make their data more discoverable
and relevant for end users

● Support for 30+ languages

● Autocomplete

● Highlighting

● Fuzzy matching (typo tolerance)

● Faceting

● Multiple data types

● Synonyms

● Scoring
Other supported search features
Search features are all about helping customers make their data more discoverable
and relevant for end users

● Support for 30+ languages

● Autocomplete dates
● Highlighting numbers
● Fuzzy matching (typo tolerance)
geoJSON
● Faceting
boolean
● Multiple data types

● Synonyms ObjectID
● Scoring
Other supported search features
Search features are all about helping customers make their data more discoverable
and relevant for end users

● Support for 30+ languages

● Autocomplete {
"mappingType": "equivalent",
"synonyms": ["car", "vehicle", "automobile"]
● Highlighting }

● Fuzzy matching (typo tolerance) {


"mappingType": "explicit",
● Faceting "input": ["beer"],
"synonyms": ["beer", "brew", "pint"]
}
● Multiple data types

● Synonyms

● Scoring
Other supported search features
Search features are all about helping customers make their data more discoverable
and relevant for end users

● Support for 30+ languages

● Autocomplete

● Highlighting

● Fuzzy matching (typo tolerance)

● Faceting

● Multiple data types

● Synonyms

● Scoring
Realm App The simplest way to stand up your app
Outsource the complexity of back-end creation,
configuration, and operations to MongoDB Realm.

Services Fully serverless — to scale with


confidence
No need to provision servers, manually configure
and maintain infrastructure, or worry about
mismatched resources causing latency or outages.

Implement dynamic application logic


Create dynamic applications that can respond to
events (like signups or database changes) in real
time.
What Realm offers

Built-in GraphQL Serverless Realm Easy-to-use triggers Data access


Functions permissions
Auto-generate JSON Define and execute Automatically run Ensure security and
schema for collections JavaScript functions functions in response privacy by defining
and query against a to build APIs, to database changes, access rules for users
single endpoint for the integrate with cloud user events, or preset across platforms and
data you need. services, and more. intervals. Realm services.
What Realm offers

Production-grade Detailed logging Embedded CLI SDKs for major


authentication platforms
Realm manages user Examine activity logs Build, export, test, and Integrate Realm into any
authentication and in the Realm UI to deploy to multiple apps with support for
integrates with discover, dissect, and environments with Android, Swift, .NET,
providers — both debug issues. programmatic Node.js, React Native,
external and internal. commands. Flutter, Kotlin, and more
We will be able to experience a fully
functional and secure client side search
application, powered by MongoDB
Atlas Search, Realm and GraphQL.

At the end
of the
workshop…
Features we will build together

Autocomplete Fuzzy search Relevance Highlighting


When searching The system must The system must The system must
movies by title, the understand when the return relevant results highlight hits so they
system should give user is misspelling and based on title, genres get visible in the
suggestions. still return relevant and countries. results.
results.
ATLAS SETUP Create an account If
you don’t have one already, go to
https://cloud.mongodb.com and
Create an Atlas create an account. Create an

Account
organization and project.

Now you can follow the


Quickstart, clicking on `Deploy a
Database`.
Quickstart
ATLAS SETUP Deploy a sandbox cluster
Simply choose free shared cluster and
follow the instructions. You can leave
Deploy a Cluster all default settings but we recommend
you name your cluster.

´Cluster0´

So it’s easier for you to follow the


tutorials, without having to change
names in strings.
Deploying a Free Cluster
Configuring security
Loading the sample data set
Quiz Time!
How many extra clusters does an Atlas user
need to provision in order to use Atlas Search?
a) 0
b) 2
c) 1
d) 3
How many extra clusters does an Atlas user
need to provision in order to use Atlas Search?
a) 0
b) 2
c) 1
d) 3
Which of the following features are
supported by Atlas Search?
a) Autocomplete
b) Faceting
c) Highlighting
d) All of the above
Which of the following features are supported by Atlas Search?
Which of the following features are
supported by Atlas Search?
a) Autocomplete
b) Faceting
c) Highlighting
d) All of the above
Which stage of the aggregation framework is
used to construct search queries?
a) $find
b) $match
c) $search
d) $meta
Which stage of the aggregation framework is
used to construct search queries?
a) $find
b) $match
c) $search
d) $meta
BREAK TIME!

Back in 10
Let’s get started with
our repo on GitHub!

https://bit.ly/34ZBfzi
SEARCH ENGINE

Atlas
Search
Design and deliver rich user experiences
with a full-text search engine built on
industry leading Apache Lucene, and
fine-tune relevance, scoring, filters,
facets and all its capabilities.
Cloud Native Search Engine
Allows you to build fast, relevant, full-text
search capabilities right on top of your data in
the cloud.

Fully Integrated and Fully Managed


Get search and database all in one place. Get
built-in search features without needing to
setup, maintain and scale a separate platform,
or replicate data elsewhere.

Indexing and Querying made Easy


Create a search index on your data with a few
clicks or a single API call. Combine dozens of
operators and options, to build sophisticated
queries.
Professional Services for Atlas Search

Migrate from Elastic, Solr,


Build your first Atlas Search Optimize your existing Atlas
and other search
application Search application
technologies

Custom engagements Jumpstart: We provide a complete development team to build search applications

Manage larger projects, multiple apps


and development work. Advisory consulting: Custom statement-of-work to provide larger advisory engagements

Consulting packages

Target a specific development phase for


one search application.
Atlas Search Foundation Atlas Search Migration Atlas Search Optimization

Instructor-led Training DS110: Atlas Search: One day crash course on Atlas Search

Develop in-house experts to build


Atlas Search Learning Path: Six day program covering development fundamentals, Atlas, and Atlas Search
search apps better, faster.
Poll
Q&A
Thank you for
your time.

You might also like