Skip to content

Text Only Unstructured Indexes

For documentation on structured indexes see here.

In this section we will go over how to create a simple unstructured index with a text field to vectorise. This is the simplest form of an index.

Creating a very basic text only unstructured index is as simple as the following:

import marqo

mq = marqo.Client(url="http://localhost:8882")

mq.create_index("my-simple-unstructured-index")

Example Add Documents Usage

Because we are using an unstructured index we need to specify the tensor fields during indexing.

documents = [
    {
        "_id": "1",
        "text_field": "New York",
    },
    {
        "_id": "2",
        "text_field": "Los Angeles",
    },
]

mq.index("my-simple-unstructured-index").add_documents(
    documents, tensor_fields=["text_field"]
)

Example search usage

This index will allow us to search the text_field field using the LEXICAL search method and the TENSOR search method.

Tensor Search (search_method="TENSOR" is the default):

results = mq.index("my-simple-unstructured-index").search(q="New York")

Lexical Search:

results = mq.index("my-simple-unstructured-index").search(
    q="New York", search_method="LEXICAL"
)