Python Client API

A thin Python wrapper around the Rest API

Pythondoc »

The Sensei Python client API help developers to build a Sensei request object and execute the query.

An example to build request and do the query:

  # create a sample sensei request
  req = SenseiRequest()
  # add paging info;
  req.set_count(50)    \
  # add query info;
  req.set_query(SenseiQueryTerm("tags", "automatic"))
  # add selection info;
  range_selection = SenseiSelectionRange("year", "1995", "2000", True, False)  # [1995 TO 2000)
  # add filter info;
  req.set_filter(SenseiFilterRange("price", 7900, 11000))
  # add group by;
  # add sort;
  req.append_sort(SenseiSort("color", True))
  # add fetch_stored
  # need explain or not
  # add facets information
  facets = SenseiFacets().add_facet("color", False, 1, 10, "hits")  \
  # execute and display results;
  proxy = SenseiServiceProxy()
  sensei_results = proxy.doQuery(req)
  sensei_results.display(["*"], max_col_width=40)
An example to get the stored source data if available:
  proxy = SenseiServiceProxy()
  print proxy.get([1,2])
  print proxy.get(['1','2'])

More examples »


Click this link to download the client file.