New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

adimeo-data-suite/php-client

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adimeo-data-suite/php-client

Source
Packagist
Version
2.2.3
Version published
Total downloads
927
Maintainers
0
Created
Source

ADS Search Client

Installation

The most efficient way to install ADS Search Client is using Composer:

composer require adimeo-data-suite/php-client

Usage

Initialisation

You must first instantiate an AdsClient object, passing to its constructor some base configuration related to your ADS server:

$searchClient = new AdsClient('http://ads.base.url', 'index.mapping', 'analyzer');

This code is sufficient for the client to perform a request on the server, given that the client will grab search context from the query string by default.

The query string parameters expected by the client are:

ParameterDescription
queryElastic style query terms
fromRecord index in the resultset
sizeNumber of records returned (to paginate)
sortField to sort results on (e.g. field,ASC or field,DESC)
filterResults filters (documentation to come)
facetOptionsFacet options (documentation to come)

Please note that AdsClient will usually generate required parameters for you. This will be explained later.

To actually search the index, just call the search() method:

$result = $searchClient->search();

Adding facets

Facets are one of the most valuable feature of a search engine compared to database search! Adding a facet to your resultset is quite straightforward:

$searchClient->addFacet(new Facet('field.raw'));

Note: field must not be tokenized to be available as facet. If it is, please also keep raw data in the index and refer to field.raw instead of field (like in the example above) to set your facet up.

Redering example

Look at the example(s) folder to see actual sample code.

To add a sticky facet, just set the matching flag on the facet:

FAQs

Package last updated on 25 May 2021

Related posts