-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (26 loc) · 1.37 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from indexer import Indexer
from searcher import Searcher
from broker import Broker
from document import Document
def main():
# Initialize Indexer with the Marqo index name
indexer = Indexer("my-first-index")
# Indexing documents using Marqo
indexer.index_documents([
Document("1", {"Title": "The Travels of Marco Polo", "Description": "A 13th-century travelogue describing Polo's travels"}),
Document("article_591", {"Title": "Extravehicular Mobility Unit (EMU)", "Description": "The EMU is a spacesuit that provides environmental protection, mobility, life support, and communications for astronauts"})
])
# Initialize Searcher with the same Marqo index name
searcher = Searcher("my-first-index")
# Searching documents using Marqo
search_results = searcher.search("What is the best outfit to wear on the moon?")
print("Search results using Marqo:")
for result in search_results:
print(result)
# If you still need the Broker for aggregating results from multiple Searchers, initialize it here
# Note: In this setup, the Broker's functionality might overlap with Marqo's search capabilities, so consider whether it's still needed
broker = Broker([searcher])
broker_results = broker.fan_out_query("Example query")
print(f"Broker aggregated search results: {broker_results}")
if __name__ == "__main__":
main()