Overview

Namespaces

  • elasticsearch

Classes

  • Config
  • Defaults
  • Faceting
  • Indexer
  • Searcher
  • Overview
  • Namespace
  • Class
  • Tree

Class Faceting

This class provides numerous helper methods for working with facet information returned from elastic search results.

Namespace: elasticsearch
License: http://opensource.org/licenses/MIT
Author: Paris Holley <mail@parisholley.com>
Version: 2.0.0
Located at Faceting.php
Methods summary
public static array
# all( string $minFont = 12, string $maxFont = 24 )

A convenient method that aggregates the results of all the other methods in the class. Example of output:

A convenient method that aggregates the results of all the other methods in the class. Example of output:

array(
// the keys are names of fields and/or taxonomies
        'taxonomy' => array(
                'available' => array(
                        'taxonomy1'     => array(
                                'count' => 10,
                                'slug'  => 'taxonomy1',
                                'name'  => 'Taxonomy One',
                                'font'  => 24
                        )
                ),
                'selected' => array(
                        'taxonomy2'     => array(
                                'slug'  => 'taxonomy2',
                                'name'  => 'Taxonomy Two'
                        )
                ),
                'total' => 10
        ),
        'rating' => array(
                'available' => array(
                        '10-20' => array(
                                'count' => 4,
                                'slug'  => '10-20',
                                'to'    => 20,
                                'from'  => 10
                        )
                ),
                'total' => 4
        )
)

Parameters

$minFont
string
$minFont The minimum font size to use for display in a tag cloud (defaults to : 12)
$maxFont
string
$maxFont The maximum font size to use for display in a tag cloud (defaults to : 24)

Returns

array
An associative array where the keys represent the data point with a list of selected and/or available options.
public static array
# range( string $field )

Analyse query parameters for range slugs and determine which facets are selected vs. which are available for the given field. Example of output:

Analyse query parameters for range slugs and determine which facets are selected vs. which are available for the given field. Example of output:

array(
        'available' => array(
                '10-20' => array(
                        'count' => 4,
                        'slug'  => '10-20',
                        'to'    => 20,
                        'from'  => 10
                )
        ),
        'selected' => array(
                '-20' => array(
                        'slug'  => '-20',
                        'to'    => 20
                )
        ),
        'total' => 4
)

Parameters

$field
string
$field The field to determine range facet information about

Returns

array
An associative array based on example provided
public static array
# taxonomy( string $tax )

Analyse query parameters for taxonomoy slugs and determine which facets are selected vs. which are available for the given field. Example of output:

Analyse query parameters for taxonomoy slugs and determine which facets are selected vs. which are available for the given field. Example of output:

array(
        'available' => array(
                'taxonomy1' => array(
                        'count' => 10,
                        'slug'  => 'taxonomy1',
                        'name'  => 'Taxonomy One',
                        'font'  => 24
                )
        ),
        'selected' => array(
                'taxonomy2'     => array(
                        'slug'  => 'taxonomy2',
                        'name'  => 'Taxonomy Two'
                )
        ),
        'total' => 10
)

Parameters

$tax
string
$field The taxonomy type to retrieve facet information about

Returns

array
An associative array based on example provided
public static integer
# cloud( array $items, array $item, string $min = 12, string $max = 24 )

Will calculate a font size based on the total number of results for the given item in a collection of items. Example of output:

Will calculate a font size based on the total number of results for the given item in a collection of items. Example of output:

array(
        'available' => array(
                'taxonomy1' => array(
                        'count' => 10,
                        'slug'  => 'taxonomy1',
                        'name'  => 'Taxonomy One',
                        'font'  => 24
                )
        ),
        'selected' => array(
                'taxonomy2' => array(
                        'slug'  => 'taxonomy2',
                        'name'  => 'Taxonomy Two'
                )
        ),
        'total' => 10
)

Parameters

$items
array
$items An array of arrays that contain a key called 'count'
$item
array
$item An item out of the array that you wish to calculate a font size
$min
string
$minFont The minimum font size to use for display in a tag cloud (defaults to : 12)
$max
string
$maxFont The maximum font size to use for display in a tag cloud (defaults to : 24)

Returns

integer
The calculated font size
public static string
# urlAdd( string $url, string $type, string $value, string $operation = 'and' )

Modifies the provided URL by appending query parameters for faceted searching.

Modifies the provided URL by appending query parameters for faceted searching.

Parameters

$url
string
$url The URL of the page that supports F.E.S
$type
string
$type The data point you wish to enable faceting for (ie: a field name or taxonomy name)
$value
string
$value The value/slug that was provided by another method call in this class
$operation
string
$operation Whether the facet should query using 'and' or 'or' (defaults to and)

Returns

string
The URL modified to support faceting
public static string
# urlRemove( string $url, string $type, string $value )

Modifies the provided URL by removing query parameters that control faceting.

Modifies the provided URL by removing query parameters that control faceting.

Parameters

$url
string
$url The URL of the page that supports F.E.S
$type
string
$type The data point you wish to remove faceting for (ie: a field name or taxonomy name)
$value
string
$value The value/slug that was provided in the URL (query parameters)

Returns

string
The URL modified to remove faceting for the provided data point
API documentation generated by ApiGen 2.8.0