> For the complete documentation index, see [llms.txt](https://koonkim.gitbook.io/mongodb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://koonkim.gitbook.io/mongodb/master/index/text-index/exercises.md).

# Exercises

## Exercise 1

* Using restaurants&#x20;
* Build a text index to the 'name' field.&#x20;
* Find restaurants whose names include 'Kyochon‘ Use text index&#x20;
* Print only borough and name fields

  ```python
  { "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.&#x20;
  * keyword -properties.admin: “South Korea”&#x20;

* Return ten documents with sorting by “properties.name”, and show the name only.&#x20;

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

  ```python
  [{'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 ‘서울대입구’&#x20;

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

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

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