Skip to content

Instantly share code, notes, and snippets.

@jkariscodes
Last active September 20, 2022 13:21
Show Gist options
  • Save jkariscodes/64206a0e43137b2ee7455a36ff95e529 to your computer and use it in GitHub Desktop.
Save jkariscodes/64206a0e43137b2ee7455a36ff95e529 to your computer and use it in GitHub Desktop.
Indexing and searching using marqo
import marqo
mq = marqo.Client(url='http://localhost:8882')
documents = [
{
"Title": "The Gods Must Be Crazy",
"Description": "An African narrative based on a South African native community.",
"ISBN": "9781234567897"
},
{
"Title": "Enchanted Forest",
"Description": "A fiction story of forest that is enchanted.",
"ISBN": "9479234567897"
},
{
"Title": "Power of Now",
"Description": "Stoic and religious inspiational teching.",
"ISBN": "9479229063871"
}
]
mq.index('book-index').add_documents(documents)
result = mq.index("book-index").search(q="A fiction story of forest that is enchanted.")
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment