This is a short and sweet, to-the-point, tutorial series that shows how to add search functionality to an iOS app using Elasticsearch for free! More specifically, in this two-part blog series, we will be creating an iOS app that uses Elastic App Search for searching a movie database. By the end of this tutorial, whether you need to search through a small movie database or through petabytes of cloud metrics, you’ll have the knowledge you need to build an amazing search experience for iOS mobile users.
Note: This tutorial is based on Elasticsearch version 7.12.x
Setup Elastic Cloud trial
- Navigate to https://www.elastic.co/cloud/.
- Choose Start free trial.
- Sign up and login.
- Choose Start your free trial.
- Select the Enterprise Search option.
- Choose to Expand the settings.
- Choose version
- Choose Create deployment.
- Download the credentials.
- Navigate to https://www.kaggle.com/edgartanaka1/tmdb-movies-an....
- Download the dataset.
- Unzip the data.
Setup App Search
- Once your deployment has been created, choose Open Enterprise Search.
- Select Launch App Search.
- Type the engine name movies
- Choose Continue
- Select Upload a JSON file.
- Drag and drop one of the movie files from the downloaded dataset.
- Choose Continue.
- Once the data is indexed successfully, choose Visit the Dashboard.
- In the list of engines, choose movies.
- In the sidebar, choose Documents to see the document you indexed.
- In the sidebar, choose Schema.
- Set the following fields to be of type Number using the drop-down options on the right:
- Set the following fields to be of type Date using the drop-down options on the right:
- Choose Confirm Types
Bulk ingest data
- In the sidebar, choose Credentials.
- Note the following fields as we will use these later:
- API Endpoint
- In your command line terminal run:
git clone email@example.com:elastic/tutorials.git
- Github Link: https://github.com/elastic/tutorials
tutorials/app-search/app_search_ingest.pyin your favorite text editor
from elastic_enterprise_search import AppSearch import glob, os import json app_search = AppSearch( "app_search_api_endpoint", http_auth="api_private_key" ) response =  print("Uploading movies to App Search...") os.chdir("movies_directory") for file in glob.glob("*.json"): with open(file, 'r') as json_file: try: response = app_search.index_documents(engine_name="movies",documents=json.load(json_file)) print(".", end='', flush=True) except: print("Fail!") print(response) break
- In the python script, replace:
app_search_api_endpointwith the API Endpoint from the credentials tab in your Enterprise Search deployment
api_private_keywith the private-key from the credentials tab in your Enterprise Search deployment
movies_directorywith the directory path of the unzipped movies data
- Example directory:
- Example directory:
- In your command line terminal, install the Elastic Enterprise Search Python library
pip3 install elastic-enterprise-search
- Run the python script
Build iOS app
Wonderful! 🎉 You should now be ingesting documents into your App Search instance. To build the iOS app, see part 2 of this blog series.