PHP 클래스 EP_API

파일 보기 프로젝트 열기: 10up/elasticpress 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( ) Placeholder method
bulk_index_posts ( $body ) : array | object | WP_Error Decode the bulk index response
create_network_alias ( array $indexes ) : array | boolean Create the network alias from an array of indexes
delete_index ( string $index_name = null ) : array | boolean Delete the current index or delete the index passed by name
delete_network_alias ( ) : boolean | array Delete the network index alias
delete_post ( integer $post_id, boolean $blocking = true ) : boolean Delete a post from the ES server given a site ID and a host site ID which is used to determine the index to delete from.
elasticpress_enabled ( $query ) : boolean Check to see if we should allow elasticpress to override this query
elasticsearch_can_connect ( ) : boolean This function checks if we can connect to Elasticsearch
factory ( ) : EP_API Return singleton instance of class
format_args ( array $args ) : array Format WP query args for ES
format_request_headers ( ) : array Add appropriate request headers
get_cluster_status ( ) : array Get cluster status
get_elasticsearch_version ( ) : string Get Elasticsearch version
get_index_status ( integer $blog_id = null ) : array Get index status
get_plugins ( ) : array Get Elasticsearch plugins
get_post ( integer $post_id ) : boolean Get a post from the index
get_query_log ( ) : array Return queries for debugging
get_search_status ( integer $blog_id = null ) : array Retrieves search stats from Elasticsearch.
get_sites ( integer $limit ) : mixed | void Wrapper function for get_sites - allows us to have one central place for the ep_indexable_sites filter
index_exists ( null $index_name = null ) : boolean Checks if index exists by index name, returns true or false
index_post ( array $post, boolean $blocking = true ) : array | boolean | mixed Index a post under a given site index or the global index ($site_id = 0)
is_empty_query ( array $response ) : boolean Check if a response array contains results or not
parse_api_response ( object $response ) : array Parse response from Elasticsearch
parse_site_id ( string $index_name ) : integer Pull the site id from the index name
prepare_meta ( object $post ) : array Prepare post meta to send to ES
prepare_meta_types ( array $post_meta ) : array Prepare post meta type values to send to ES
prepare_meta_value_types ( mixed $meta_value ) : array Prepare meta types for meta value
prepare_post ( integer $post_id ) : boolean | array Prepare a post for syncing
put_mapping ( ) : array | boolean | mixed Send mapping to ES
query ( array $args, array $query_args, string $scope = 'current' ) : array Search for posts under a specific site index or the global index ($site_id = 0).
refresh_index ( ) : boolean Refresh the current index
remote_request ( string $path, array $args = [], array $query_args = [] ) : WP_Error | array Wrapper for wp_remote_request

보호된 메소드들

메소드 설명
_add_query_log ( array $query ) : void Query logging. Don't log anything to the queries property when WP_DEBUG is not enabled. Calls action 'ep_add_query_log' if you want to access the query outside of the ElasticPress plugin. This runs regardless of debufg settings.
parse_order ( string $order ) : string Parse an 'order' query variable and cast it to ASC or DESC as necessary.
parse_orderby ( string $orderbys, $default_order, array $args ) : array Convert the alias to a properly-prefixed sort value.
sanitize_taxonomy_names ( $taxonomies ) : array WP is using 'weird' taxonomy name, for example: 'category' but in query using 'category_name', 'post_tag' but in queries using 'tag' Map taxonomy name in db to taxonomy in query

비공개 메소드들

메소드 설명
get_parent_terms ( $terms, $term, $tax_name ) : array Recursively get all the ancestor terms of the given term
prepare_date_terms ( $post_date_gmt ) : array Prepare date terms to send to ES.
prepare_terms ( object $post ) : array Prepare terms to send to ES.

메소드 상세

__construct() 공개 메소드

Placeholder method
부터: 0.1.0
public __construct ( )

_add_query_log() 보호된 메소드

Query logging. Don't log anything to the queries property when WP_DEBUG is not enabled. Calls action 'ep_add_query_log' if you want to access the query outside of the ElasticPress plugin. This runs regardless of debufg settings.
protected _add_query_log ( array $query ) : void
$query array Query.
리턴 void Method does not return.

bulk_index_posts() 공개 메소드

Decode the bulk index response
부터: 0.9.2
public bulk_index_posts ( $body ) : array | object | WP_Error
$body
리턴 array | object | WP_Error

create_network_alias() 공개 메소드

Create the network alias from an array of indexes
부터: 0.9.0
public create_network_alias ( array $indexes ) : array | boolean
$indexes array
리턴 array | boolean

delete_index() 공개 메소드

Delete the current index or delete the index passed by name
부터: 0.9.0
public delete_index ( string $index_name = null ) : array | boolean
$index_name string
리턴 array | boolean

delete_network_alias() 공개 메소드

Delete the network index alias
부터: 0.9.0
public delete_network_alias ( ) : boolean | array
리턴 boolean | array

delete_post() 공개 메소드

Delete a post from the ES server given a site ID and a host site ID which is used to determine the index to delete from.
부터: 0.1.0
public delete_post ( integer $post_id, boolean $blocking = true ) : boolean
$post_id integer
$blocking boolean
리턴 boolean

elasticpress_enabled() 공개 메소드

Check to see if we should allow elasticpress to override this query
부터: 0.9.2
public elasticpress_enabled ( $query ) : boolean
$query
리턴 boolean

elasticsearch_can_connect() 공개 메소드

This function checks if we can connect to Elasticsearch
부터: 2.1

factory() 공개 정적인 메소드

Return singleton instance of class
부터: 0.1.0
public static factory ( ) : EP_API
리턴 EP_API

format_args() 공개 메소드

Format WP query args for ES
부터: 0.9.0
public format_args ( array $args ) : array
$args array
리턴 array

format_request_headers() 공개 메소드

Add appropriate request headers
부터: 1.4
public format_request_headers ( ) : array
리턴 array

get_cluster_status() 공개 메소드

Retrieves cluster stats from Elasticsearch.
부터: 1.9
public get_cluster_status ( ) : array
리턴 array Contains the status message or the returned statistics.

get_elasticsearch_version() 공개 메소드

Get Elasticsearch version
부터: 2.1.2

get_index_status() 공개 메소드

Retrieves index stats from Elasticsearch.
부터: 1.9
public get_index_status ( integer $blog_id = null ) : array
$blog_id integer Id of blog to get stats.
리턴 array Contains the status message or the returned statistics.

get_plugins() 공개 메소드

Gets a list of available Elasticearch plugins.
부터: 1.9
public get_plugins ( ) : array
리턴 array Array of plugins and their version or error message

get_post() 공개 메소드

Get a post from the index
부터: 0.9.0
public get_post ( integer $post_id ) : boolean
$post_id integer
리턴 boolean

get_query_log() 공개 메소드

Return queries for debugging
부터: 1.8
public get_query_log ( ) : array
리턴 array

get_search_status() 공개 메소드

Retrieves various search statistics from the ES server.
부터: 1.9
public get_search_status ( integer $blog_id = null ) : array
$blog_id integer Id of blog to get stats.
리턴 array Contains the status message or the returned statistics.

get_sites() 공개 메소드

Wrapper function for get_sites - allows us to have one central place for the ep_indexable_sites filter
public get_sites ( integer $limit ) : mixed | void
$limit integer The maximum amount of sites retrieved, Use 0 to return all sites
리턴 mixed | void

index_exists() 공개 메소드

Checks if index exists by index name, returns true or false
public index_exists ( null $index_name = null ) : boolean
$index_name null
리턴 boolean

index_post() 공개 메소드

Index a post under a given site index or the global index ($site_id = 0)
부터: 0.1.0
public index_post ( array $post, boolean $blocking = true ) : array | boolean | mixed
$post array
$blocking boolean
리턴 array | boolean | mixed

is_empty_query() 공개 메소드

Check if a response array contains results or not
부터: 0.1.2
public is_empty_query ( array $response ) : boolean
$response array
리턴 boolean

parse_api_response() 공개 메소드

Determines if there is an issue or if the response is valid.
부터: 1.9
public parse_api_response ( object $response ) : array
$response object JSON decoded response from Elasticsearch.
리턴 array Contains the status message or the returned statistics.

parse_order() 보호된 메소드

Parse an 'order' query variable and cast it to ASC or DESC as necessary.
부터: 1.1
protected parse_order ( string $order ) : string
$order string The 'order' query variable.
리턴 string The sanitized 'order' query variable.

parse_orderby() 보호된 메소드

Convert the alias to a properly-prefixed sort value.
부터: 1.1
protected parse_orderby ( string $orderbys, $default_order, array $args ) : array
$orderbys string Alias or path for the field to order by.
$args array
리턴 array

parse_site_id() 공개 메소드

Pull the site id from the index name
부터: 0.9.0
public parse_site_id ( string $index_name ) : integer
$index_name string
리턴 integer

prepare_meta() 공개 메소드

Prepare post meta to send to ES
부터: 0.1.0
public prepare_meta ( object $post ) : array
$post object
리턴 array

prepare_meta_types() 공개 메소드

Prepare post meta type values to send to ES
public prepare_meta_types ( array $post_meta ) : array
$post_meta array
리턴 array

prepare_meta_value_types() 공개 메소드

Prepare meta types for meta value
public prepare_meta_value_types ( mixed $meta_value ) : array
$meta_value mixed
리턴 array

prepare_post() 공개 메소드

Prepare a post for syncing
부터: 0.9.1
public prepare_post ( integer $post_id ) : boolean | array
$post_id integer
리턴 boolean | array

put_mapping() 공개 메소드

Send mapping to ES
부터: 0.9.0
public put_mapping ( ) : array | boolean | mixed
리턴 array | boolean | mixed

query() 공개 메소드

Search for posts under a specific site index or the global index ($site_id = 0).
부터: 0.1.0
public query ( array $args, array $query_args, string $scope = 'current' ) : array
$args array
$query_args array Strictly for debugging
$scope string
리턴 array

refresh_index() 공개 메소드

Refresh the current index
부터: 0.9.0
public refresh_index ( ) : boolean
리턴 boolean

remote_request() 공개 메소드

This is a wrapper function for wp_remote_request to account for request failures.
부터: 1.6
public remote_request ( string $path, array $args = [], array $query_args = [] ) : WP_Error | array
$path string Site URL to retrieve.
$args array Optional. Request arguments. Default empty array.
$query_args array Optional. The query args originally passed to WP_Query
리턴 WP_Error | array The response or WP_Error on failure.

sanitize_taxonomy_names() 보호된 메소드

WP is using 'weird' taxonomy name, for example: 'category' but in query using 'category_name', 'post_tag' but in queries using 'tag' Map taxonomy name in db to taxonomy in query
protected sanitize_taxonomy_names ( $taxonomies ) : array
$taxonomies
리턴 array