AI API - Hybrid search grouped by page or Drupal entity (vdb_search)

AI API: Vectors, Images & LLM

Searches your index by words and meaning in one ranking, with the hybrid search of the hosted search page, and groups the results: one per Drupal entity, or one per page or document.

Endpointhttps://api.opensolr.com/solr_manager/api/vdb_search
MethodGET or POST, a JSON body works too
Authemail and api_key of your account, as GET or POST parameters: Authentication.

01 · Parameters

index_nameRequired

Your index.

keysOptional

The search text, up to 2000 characters. Without it: the latest documents.

siteOptional

1: every document of the index, one result per page or document. Default: only documents of Drupal entities, one result per entity.

modeOptional

lexical: words only, no vector. Default: words and meaning.

vectorOptional

Your own query vector, of the size vdb_info gives. Without it, the words are turned into one.

limit, offsetOptional

limit 1 to 100, default 10. offset up to 10000.

languagesOptional

Only these languages, such as ["en","de"].

from, toOptional

Only documents created between these days, YYYY-MM-DD.

freshOptional

1 favours recent documents, 0 does not. Default: the Search Tuning of the index.

passagesOptional

Also give each result about this many characters of its text around the words, 200 to 10000: for a chat bot.

excludeOptional

Drupal entity ids to leave out.

02 · Example

curl -s "https://api.opensolr.com/solr_manager/api/vdb_search?email=YOUR_EMAIL&api_key=YOUR_API_KEY&index_name=my_index&site=1&limit=5" --data-urlencode "keys=how to assemble the blue chair"

03 · Answer

{
    "status": true,
    "num_found": 12,
    "results": [
        {
            "id": "...",
            "drupal_entity_id": "",
            "title": "Blue chair manual",
            "uri": "https://www.example.com/manuals/blue-chair.pdf#page=3",
            "content": "... <em>assemble</em> the legs first ...",
            "price": null,
            "currency": null,
            "date": "...",
            "distance": 0.82,
            "highlighted_fields": {
                "title": [
                    "..."
                ],
                "body": [
                    "..."
                ]
            },
            "pages": [
                {
                    "id": "...",
                    "page": 4,
                    "uri": "https://www.example.com/manuals/blue-chair.pdf#page=4",
                    "title": "...",
                    "snippet": "..."
                }
            ]
        }
    ]
}

pages holds the other matching pages of the same document. A PDF result links its page. With passages, each result and page also has passage. Values shown are an example.

When the words are turned into a vector here, that counts one AI request; a vector sent by you, or a search made before, costs nothing. Every plan includes a monthly allowance of AI requests: API Quota, Pricing. The allowance used is the one of the account that owns the index.

04 · Errors

VECTOR_NOT_ALLOWEDHTTP 200

AI is switched off on the plan of the index owner.

ERROR_EMBEDDING_SERVICE_UNAVAILABLEHTTP 200

The embedding model did not answer. Retry, or use mode=lexical.

ERROR_SOLR_SEARCHHTTP 200

The index did not answer the search; detail says why.

ERROR_NOT_CORE_OWNERHTTP 200

The index is not yours.

WRONG_API_HOSTHTTP 404

Called on opensolr.com.

ERROR_AUTHENTICATION_FAILEDHTTP 403

The email and API key do not match.

05 · Related

Hybrid search with the hosted search page answer: embed_and_search.

Every error code and HTTP status of the API: API errors. Calls per minute and per hour: Rate limits.