logo

English

Search



Notice !

Results are cached for 2 minutes and changes (like updating a document) will not be applied for the same query until 10 minutes pass.
GET /api/v2/projects/{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, set it to default if you have not created your own custom search handler.

Querystring parameters:

  1. q: the search query, e.x ?q=lableb.
  2. filter: a list of filters, e.x ?filter=tags:"Tech"&filter=tags:"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. sort: You can sort the search results using the sort parameter by defining which field you want to sort the results. it can be ascending(asc) or descending(desc), e.x ?sort=tags desc.
  6. session_id: a unique identifier for a user session, e.x ?session_id=1xHsxW342.
  7. user_id: a unique identifier for a user, e.x ?user_id=1.
  8. user_ip: user ip address, e.x ?user_ip=192.111.24.21.
  9. user_country: user country code, e.x ?user_country=DE.

Example request:

http://api-bahuth.lableb.com/api/v2/projects/wptest/collections/posts/search/default
  ?q=lableb
  &skip=5
  &limit=10
  &sort=id asc
  &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
  }
}