Pugpig App Search API
Table of Contents
Pugpig has an API for searching across all content for a publication. It's currently used by the Pugpig search products and the apps' lookup service, but can also be opened up to third parties developing extensions to Pugpig apps.
Have a look at our general overview of search in Bolt for more information on the search index and user experience.
URL formats
Search for a keyword across all editions:
http://feed-publication-account.api.pugpig.com/search/all/keyword
Search for a keyword in just one Collection (Timeline or Edition), specified by a Collection ID:
http://feed-publication-account.api.pugpig.com/search/com.account.publication.150515/keyword
To search by article publish date add the date range to the end of the search URL like this:
?sd=2014-10-25T00:00:00Z&
For multiple keywords separate with a '+'
Syntax for category search
Using the category API allows you to make faceted queries. Categories are added to the query string like:
cats[0]
cats[1]
etc
A matching document must have ALL the supplied categories
The parameter value must be the category and the value separated by a |
For example: http://schema.pugpig.com/pagetype|pugpig_feature
For example, to find all articles with:
Category: http://schema.pugpig.com/pagetype = "pugpig_feature"
AND
Category: http://schema.pugpig.com/section = "Feature"
After URL encoding it should look like this:
/search/all/-pig?cats[0]=http%3A%2F%2Fschema.pugpig.com%2Fpagetype%7Cpugpig_feature&cats[1]=http%3A%2F%2Fschema.pugpig.com%2Fsection%7CFeature
Excluding categories
In order to completely exclude categories, you can use the same syntax as above but use xcats instead of cats
Sorting your results
By default, results are sorted by relevance. Other options for the sort parameter are:
- score (default) - sort by the document score (i.e. relevance)
- published_date - sorted by published date for the article, most recent first
- edition - sort by edition published date, most recent first. Useful for grouping results by edition
Syntax for page size & pagination
You can specify the page size using &size=XX on the query string, where XX is between 1 and 200. The default is 20
You can specify the first result using "&start=XX" on the query string. The default is 0. So for page 2 with a page size of 20, using start=20.
The information for your paging is returning in the following categories:
<category scheme="http://schema.pugpig.com/search/num_results" term="219"/>
<category scheme="http://schema.pugpig.com/search/result_start" term="2"/>
<category scheme="http://schema.pugpig.com/search/page_size" term="20"/>
Authentication Tokens
When retrieving results, it may be necessary to provide content tailored to a particular user (such as paid content). In these instances, we ensure authentication by passing the authentication token with search request. To accomplish this, ensure the token is passed as a header with the GET request. Specifically, set the x-pugpig-user-search-token
header to include the authentication token.
For guidance on accessing the token using the pugpigBridgeService
, refer to the userInfo
object within the authorisationStatus
bridge method, as outlined here: https://docs.pugpig.com/bolt-bridge-reference#authorisationstatus-2)