logo

English

Recommendation



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}/recommend/.
OR
GET /api/v2/projects/{project}/collections/{collection}/recommend/{handler}.
You can use the first endpoint to access a recommendations query configured with a request handler called “recommend”. Otherwise, you must specify the request handler as in the second endpoint.
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} OPTIONAL - recommendation handler name - recommend by default.

Querystring parameters:

  1. id: ID of the source document REQUIRED.
  2. filter: a list of filters, e.x ?filter=tags:"Tech"&filter=tags:"Computer".
  3. title: the title of the source document, e.x ?title=lableb engine is awesome.
  4. url: the url of the source document, e.x ?url=http://mysite.com/posts/lableb-is-awesome.
  5. limit: number of returned documents, e.x ?limit=3.
  6. 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.
  7. session_id: a unique identifier for a user session, e.x ?session_id=1xHsxW342.
  8. user_id: a unique identifier for a user, e.x ?user_id=1.
  9. user_ip: user ip address, e.x ?user_ip=192.111.24.21.
  10. user_country: user country code, e.x ?user_country=DE.

Example request:

https://api-bahuth.lableb.com/api/v2/projects/wptest/collections/posts/recommend/default
  ?id=1
  &title=lableb engine is awesome
  &session_id=1c4Hb23
  &limit=3
  &token=qxDFI791xxxx-8wmxIBIONYiEK44PGnxxxxxx

Example response:

{
  "time": 66,
  "code": 200,
  "response": {
    "found_documents": 20,
    "results": [
      {
        "date": "2019-04-29T08:29:30.000+0000",
        "image": "http://example.com/static/images/lableb.png",
        "categories": ["Tech", "Search"],
        "id": "1",
        "title": "Million reason to use Lableb cloud search",
        "content": "Example content",
        "url": "http://mysite.com/posts/million-reason-to-use-lableb",
        "tags": ["Fast", "Accurate"]
      }
    ],
    "facets": {
      "count": 3,
      "categories": {
        "buckets": [{ "value": "Cloud Search", "count": 25 }]
      },
      "tags": { "buckets": [] },
      "year": { "buckets": [] },
      "authors": { "buckets": [] }
    },
    "spelling": null
  }
}