Introduction to MongoDB
1.0 - draft
1.0 - draft
  • MongoDB
  • Getting Started
    • General
      • Database? Collection? Schema?
      • RDBMS? NoSQL?
      • Scale-Up ? Scale - out?
      • JavaScript Object Notation
    • MongoDB
      • 간략한 역사,
    • Manipulating Database
      • MongoShell
      • PyMongo
  • CRUD
    • General
      • Explain()
      • mongoimport
    • Create
      • Mongo Shell
      • PyMongo
      • Exercises
    • Read
      • Mongo Shell
      • PyMongo
      • Exercises
    • Update
      • Mongo Shell
      • PyMongo
      • Exercises
    • Delete
      • PyMongo
      • Exercises
    • Challenging Exercises
      • Exercise 1
  • Index with Geospatial & Text
    • Basic Index
      • Syntax
      • Exercises
    • Geospatial Index
      • Syntax
      • Exercises
    • Text Index
      • Syntax
      • Exercises
    • Challenge
  • Aggregate framework
    • Aggregate Framework
      • Basic
      • Exercises
  • Distributed
    • Replication
      • Setup
        • Configuration File
        • Running Servers
        • Initiation
        • Exercises
      • Concerns
        • Read Concern
        • Write Concern
        • Exercises
    • Sharding
      • Getting Started
      • Setup
  • MongoDB 4.0 Features
    • Multi-Document Transaction
      • Transaction?
      • Basic
      • Exercises
  • Administration
    • Untitled
Powered by GitBook
On this page
  • Exercise 1
  • Exercise 2

Was this helpful?

  1. Index with Geospatial & Text
  2. Text Index

Exercises

Exercise 1

  • Using restaurants

  • Build a text index to the 'name' field.

  • Find restaurants whose names include 'Kyochon‘ Use text index

  • Print only borough and name fields

    { "borough" : "Queens", "name" : "Kyochon Chicken" }
    { "borough" : "Manhattan", "name" : "Kyochon" }

Exercise 2

  • Take a look the index information in map and countries collections.

  • Find universities in Korea.

    • Get geometry information in the countries collection.

    • keyword -properties.admin: “South Korea”

  • Return ten documents with sorting by “properties.name”, and show the name only.

    • Note that there is no ‘properties.name’ in a document; therefore, remove the document.

    [{'properties': {'name': 'GIST 광주 과학 기술원'}},
     {'properties': {'name': 'ICT폴리택대학'}},
     {'properties': {'name': 'KAIST 문지 캠퍼스'}},
     {'properties': {'name': 'KC대학교'}},
     {'properties': {'name': 'KT원주연수원'}},
     {'properties': {'name': 'U1대학교 아산캠퍼스'}},
     {'properties': {'name': '가천대학교 글로벌캠퍼스'}},
     {'properties': {'name': '가천대학교 메디컬캠퍼스'}},
     {'properties': {'name': '가톨릭관동대학교'}},
     {'properties': {'name': '가톨릭대학교 성신교정'}}]

  • Search the ‘properties.name’ that includes ‘서울대입구’

  • Using regular expression ($regex) or a text index.

  • Sort properties.name in ascending order and display only a name field as below.

    [{'properties': {'name': '서울대입구 삼성아파트'}},
     {'properties': {'name': '서울대입구 풍림아이원 1단지'}},
     {'properties': {'name': '서울대입구 풍림아이원 2단지'}}]

PreviousSyntaxNextChallenge

Last updated 5 years ago

Was this helpful?