Skip to content

Bulk Operations

For improved throughput and performance, certain operations have equivalent bulk methods.

POST /indexes/bulk/search

Body

Search Parameter Type Default value Description
queries List [] List of query requests. Query request has the same parameters as the body of /indexes/{index_name}/search, but index must be specified as "index". See example below for detail.

Note: The parameter context is not supported in bulk api yet.

Query parameters

Search Parameter Type Default value Description
device String cpu The device used to search. This allows you to use cuda GPUs to speed up indexing, if available. Options include cpu and cuda, cuda1, cuda2 etc. The cuda option tells Marqo to use all available cuda devices.

Response

Name Type Description
result Array of objects In-order results of each search query. Object structure matches that of /indexes/{index_name}/search.
processingTimeMs Number Processing time of the query

Example

curl -XPOST 'http://localhost:8882/indexes/bulk/search' -H 'Content-type:application/json' -d '
{"queries": [{
        "index": "my-first-index",
        "q": "what is the best outfit to wear on the moon?",
        "searchableAttributes": ["Description"],
        "limit": 10,
        "offset": 0,
        "showHighlights": True,
        "filter": "*:*",
        "searchMethod": "TENSOR",
        "attributesToRetrieve": ["Title", "Description"]
    },{
        "index": "my-second-index",
        "attributesToRetrieve": ["_id"],
        "q": {"what is the best outfit to wear on mars?": 0.5, "what is the worst outfit to wear on mars?": 0.3}
    }]
}' 
mq.bulk_search([
    {
        "index": "my-first-index",
        "q": "what is the best outfit to wear on the moon?",
        "searchableAttributes": ["Description"],
        "limit": 10,
        "offset": 0,
        "showHighlights": True,
        "filter": "*:*",
        "searchMethod": "TENSOR",
        "attributesToRetrieve": ["Title", "Description"]
    },{
        "index": "my-second-index",
        "attributesToRetrieve": ["_id"],
        "q": {"what is the best outfit to wear on mars?": 0.5, "what is the worst outfit to wear on mars?": 0.3}
    }]
)

Note: In Python, the body expects lower camelcase parameters (e.g. "attributesToRetrieve") unlike the standard Python search method (i.e. mq.index("index_name").search(...) which has many keyword arguments provided as snake case (e.g. search(attributes_to_retrieve=[])

Response: 200 Ok

{
    "result": [
        {
            "hits": [
                {
                    "Title": "Extravehicular Mobility Unit (EMU)",
                    "Description": "The EMU is a spacesuit that provides environmental protection, mobility, life support, and communications for astronauts",
                    "_highlights": {
                        "Description": "The EMU is a spacesuit that provides environmental protection, mobility, life support, and communications for astronauts"
                    },
                    "_id": "article_591",
                    "_score": 1.2387788
                },
                {
                    "Title": "The Travels of Marco Polo",
                    "Description": "A 13th-century travelogue describing Polo's travels",
                    "_highlights": {"Title": "The Travels of Marco Polo"},
                    "_id": "e00d1a8d-894c-41a1-8e3b-d8b2a8fce12a",
                    "_score": 1.2047464
                }
            ],
            "limit": 10,
            "offset": 0,
            "processingTimeMs": 49,
            "query": "What is the best outfit to wear on the moon?"
        },{
            "hits": [
                {
                    "_id": "article_591",
                    "_score": 1.2387788
                },
                {
                    "_id": "e00d1a8d-894c-41a1-8e3b-d8b2a8fce12a",
                    "_score": 1.2047464
                }
            ],
            "limit": 10,
            "offset": 0,
            "processingTimeMs": 42,
            "query": {"what is the best outfit to wear on mars?": 0.5, "what is the worst outfit to wear on mars?": 0.3}
        }
    ]
}