Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Build Applications with Meteor

You're reading from   Build Applications with Meteor Isomorphic JavaScript web development

Arrow left icon
Product type Paperback
Published in May 2017
Publisher Packt
ISBN-13 9781787129887
Length 388 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Dobrin Ganev Dobrin Ganev
Author Profile Icon Dobrin Ganev
Dobrin Ganev
Arrow right icon
View More author details
Toc

Index a text field


In order to do a full-text search on a collection, we need to index a text field(s). Any field in our collection of the type string can be indexed; it can be just one field or all of them.

Let's start exploring the imported data by querying it in the shell.

Without stopping the application, open another terminal in the app directory and start the mongo shell:

>> meteor mongo

To see all the databases in our application, we can use the following command:

meteor:PRIMARY> show dbs
local 0.009GB
meteor 0.005GB

To switch to the meteor database, use:

meteor:PRIMARY> use meteor
switched to db meteor

To show all the collections in the database, use:

meteor:PRIMARY> show collections
restaurants

To count the number of documents in the restaurant collection, use:

meteor:PRIMARY> db.restaurants.count()
25359

We have imported 25,359 documents in our collection. To get the first document of the collection, we can perform the following query:

meteor:PRIMARY> db.restaurants.findOne...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime