--- title: Indexer keywords: fastai sidebar: home_sidebar nb_path: "nbs/indexers.indexer.ipynb" ---
When we run an indexer we have four steps. 1) Get the indexer and indexer run based on the run uid. 2) run the indexer 3) populate the graph with the new information. To mock that, first we create a client and add some toy data.
from integrators.indexers.geo.geo_indexer import GeoIndexer
client = PodClient()
location = Location.from_data(latitude=-37.81, longitude=144.96)
address = Address.from_data()
indexer = Indexer.from_data(indexerClass="GeoIndexer", name="GeoIndexer")
indexer_run = IndexerRun.from_data(progress=0, targetDataType="Address")
for x in [location, address, indexer, indexer_run]: client.create(x)
edge_success = client.create_edge(Edge(indexer_run, indexer, "indexer"))
edge_success2 = client.create_edge(Edge(location, address, "location"))
assert edge_success and edge_success2
Before we can move on, we need to make sure that our indexer is registred. This hold for any integrator that we create.
{% include important.html content='Note that before running an indexer, it needs to be registered. We can do this by importing the file in integrators.indexer_registry.py.' %}
test_registration(GeoIndexer)
Now we start with the setting we would normally have: some memri client makes a call to the pod to execute an indexer run. Lets start by getting the indexer and the indexer run.
indexer_run = client.get(indexer_run.uid)
indexer = indexer_run.indexer[0]
Next, we retrieve the data, which was specified in the client by the targetDataType.
data = indexer.get_data(client, indexer_run)
updated_items, new_items = indexer.index(data, indexer_run, client)
indexer.populate(client, updated_items, new_items)