logo

English

Search



Notice !

Results are cached for 10 minutes and changes (like updating a document) will not be applied for the same query until 10 minutes pass.
GET /api/v1/{project}/collections/{collection}/search/{handler}
Where:
  1. {project} is your project name, e.x wptest.
  2. {collection} is the name of collection of documents you want to search in, e.x posts.
  3. {handler} search handler name, e.x default.

Querystring parameters:

  1. q: the search query, e.x ?q=lableb.
  2. filter: a list of filters, e.x ?filter=meta_sa:"Tech"&filter=meta_sa:"Computer".
  3. skip: how many documents to skip (used for pagination), e.x ?skip=10.
  4. limit: how many documents to fetch (used for pagination), e.x ?limit=5.
  5. session_id: a unique identifier for a user session, e.x ?session_id=1xHsxW342.
  6. user_id: a unique identifier for a user, e.x ?user_id=1.
  7. user_ip: user ip address, e.x ?user_ip=192.111.24.21.
  8. user_country: user country code, e.x ?user_country=DE.

Example request:

http://api-bahuth.lableb.com/api/v1/wptest/collections/posts/search/default
  ?q=lableb
  &skip=5
  &limit=10
  &session_id=1c4Hb23
  &token=qxDFI791xxxx-8wmxIBIONYiEK44PGnxxxxxx

Example response:

{
  "time": 11,
  "code": 200,
  "response": {
    "found_documents": 53,
    "results": [
      {
        "date": "2018-12-25T10:24:00.000+0000",
        "image": "https://example.com/static/example.jpg",
        "categories": ["Search"],
        "id": "1",
        "title": "Example title content",
        "content": "Example post content",
        "url": "http://mysite.com/posts/labelb-cloud-search/"
      }
    ],
    "facets": {
      "count": 3,
      "categories": {
        "buckets": [{ "value": "Search", "count": 3 }]
      },
      "tags": {
        "buckets": [{ "value": "Tech", "count": 1 }]
      },
      "authors": { "buckets": [] },
      "year": {
        "buckets": [{ "value": 2019, "count": 5 }]
      }
    },
    "spelling": null
  }
}