<commit_before><?php
namespace elasticsearch;

/**
* The searcher class provides all you need to query your ElasticSearch server.
*
* @license http://opensource.org/licenses/MIT
* @author <NAME> <<EMAIL>>
* @version 2.0.0
**/
class Searcher{
	/**
	* Initiate a search with the ElasticSearch server and return the results. Use Faceting to manipulate URLs.
	* @param string $search A space delimited list of terms to search for
	* @param integer $pageIndex The index that represents the current page
	* @param integer $size The number of results to return per page
	* @param array $facets An object that contains selected facets (typically the query string, ie: $_GET)
	* @param boolean $sortByDate If false, results will be sorted by score (relevancy)
	* @see Faceting
	* 
	* @return array The results of the search
	**/
	public static function search($search, $pageIndex = 0, $size = 10, $facets = array(), $sortByDate = false){
		$args = self::_buildQuery($search, $facets);

		if(empty($args) || (empty($args['query']) && empty($args['facets']))){
			return array(
				'total' => 0,
				'ids' => array(),
				'facets' => array()
			);
		}

		return self::_query($args, $pageIndex, $size, $sortByDate);
	}

	/**
	* @internal
	**/
	public static function _query($args, $pageIndex, $size, $sortByDate = false){
		$query =new \Elastica\Query($args);
		$query->setFrom($pageIndex * $size);
		$query->setSize($size);
		$query->setFields(array('id'));
<commit_msg>fix wordpress from slashing<commit_after><?php
namespace elasticsearch;

/**
* The searcher class provides all you need to query your ElasticSearch server.
*
* @license http://opensource.org/licenses/MIT
* @author <NAME> <<EMAIL>>
* @version 2.0.0
**/
class Searcher{
	/**
	* Initiate a search with the ElasticSearch server and return the results. Use Faceting to manipulate URLs.
	* @param string $search A space delimited list of terms to search for
	* @param integer $pageIndex The index that represents the current page
	* @param integer $size The number of results to return per page
	* @param array $facets An object that contains selected facets (typically the query string, ie: $_GET)
	* @param boolean $sortByDate If false, results will be sorted by score (relevancy)
	* @see Faceting
	* 
	* @return array The results of the search
	**/
	public static function search($search, $pageIndex = 0, $size = 10, $facets = array(), $sortByDate = false){
		$search = str_replace('\"', '"', $search);

		$args = self::_buildQuery($search, $facets);

		if(empty($args) || (empty($args['query']) && empty($args['facets']))){
			return array(
				'total' => 0,
				'ids' => array(),
				'facets' => array()
			);
		}

		return self::_query($args, $pageIndex, $size, $sortByDate);
	}

	/**
	* @internal
	**/
	public static function _query($args, $pageIndex, $size, $sortByDate = false){
		$query =new \Elastica\Query($args);
		$query->setFrom($pageIndex * $size);
		$query->setSize($size);
		$query->setFields(array('id'));

{'fraction_non_alphanumeric': 0.1494291470785762, 'fraction_numerical': 0.0047011417058428475, 'mean_word_length': 4.406533575317605, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5084696', 'n_tokens_mistral': 996, 'n_tokens_neox': 937, 'n_words': 318}