Antidot PHP API  version 0.16.0
##PHP API to simplify integration of Antidot components
 All Classes Files Functions Variables Groups Pages
AFS search query API

Table of Contents

Introduction

This API simplifies querying of Antidot search engine. Classes involved in this API are detailled and, when possible, examples are given.

Snippets of code are usable as is and can be joined to build a fully functional example step by step. If you prefer you can get access to full code example full_example.php.

If you have not read it yet you can start by reading AFS search query coder/decoder API.

AFS search connector

Instance of AfsSearchConnector is initialized with specific search URL and an instance of AfsService.

Specific search URL is provided by production team and should be similar to http://your_company.afs-antidot.net/search

Along with the search URL, a service number and service status should also have been provided. These informations are used to initialized an instance of AfsService. Production services are not modified in place so their status are usually stable.

Here an example to initialize an AFS search connector:

$host = 'eval.partners.antidot.net';
$connector = new AfsSearchConnector($host, $service);

Once the connector is initialized, queries can be submitted by calling AfsSearchConnector::send method. This method is generally never called directlty. Instead, call to AfsSearchQueryManager::send (see Query manager) triggers appropriate call to this method.

An array of parameters should be provided to the method. Array key/value pairs should correspond to valid AFS search engine parameter names with valid associated value (see AFS Integration Guide > AFS WEB SERVICES > search > Parameters).
Provided array of parameters is filled with default parameters such as afs:service, afs:status and afs:output before Antidot search engine is queried.

Facets management

Facets can be declared and configured by instantiating AfsFacet. The two most important parameters are the facet id and the facet type. These parameters should correspond to the ones provided in the feed description file on the PaF side.

Each facet should be added to an instance of AfsFacetManager. The order in which facets are added to the manager is highly important because it implies the order in which facets will appear in Antidot search engine reply.

Example of facet and facet manager initialization:

$facet_mgr = $query->get_facet_manager();
$facet_mgr->add_facet(new AfsFacet('Organization', AfsFacetType::STRING_TYPE));
$facet_mgr->add_facet(new AfsFacet('date_parution', AfsFacetType::DATE_TYPE));
$facet_mgr->add_facet(new AfsFacet('media', AfsFacetType::STRING_TYPE));
$facet_mgr->add_facet(new AfsFacet('person', AfsFacetType::STRING_TYPE));
$facet_mgr->add_facet(new AfsFacet('source', AfsFacetType::STRING_TYPE));
$facet_mgr->add_facet(new AfsFacet('taxo_iptc', AfsFacetType::STRING_TYPE));
$facet_mgr->add_facet(new AfsFacet('theme', AfsFacetType::STRING_TYPE));
$facet_mgr->add_facet(new AfsFacet('annotated_city', AfsFacetType::STRING_TYPE));
$facet_mgr->add_facet(new AfsFacet('date', AfsFacetType::DATE_TYPE));
$facet_mgr->add_facet(new AfsFacet('stationParRegion', AfsFacetType::STRING_TYPE));

Query

Details on queries are provided in Query.

Here a summarize of the query usages:

Reminder of query initialization:

$coder = new AfsQueryCoder('full_example.php');
$query = $coder->build_query($_GET);

Query manager

Query manager combine all previous elements to connect and send query to Antidot search engine. No specific configuration is necessary.

Example of query manager initialization:

$reply = $query_mgr->send($query);

Next step

AFS search reply API