A tiny text index records which documents contain an exact word.

Text Index

text_index.py
documents = [
    "trace source code",
    "source replay view",
    "static trace page",
]

term = 

matches = []
for number, text in enumerate(documents, start=1):
    words = text.split()
    if term in words:
        matches.append(str(number))

print("matches=" + ",".join(matches))
documents = [
    "trace source code",
    "source replay view",
    "static trace page",
]

term = 

matches = []
for number, text in enumerate(documents, start=1):
    words = text.split()
    if term in words:
        matches.append(str(number))

print("matches=" + ",".join(matches))
exact-word search Splitting text into words makes an exact membership test visible in the trace.