# 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단지'}}]
  ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://koonkim.gitbook.io/mongodb/master/index/text-index/exercises.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
