<commit_before><?php

/**
 * ProcessWire DatabaseQuerySelectFulltext
 *
 * A wrapper for SELECT SQL queries using FULLTEXT indexes
 * 
 * Decorates a DatabaseQuerySelect object by providing the WHERE and 
 * ORDER parts for a fulltext query based on the table, field, operator 
 * and value you are searching. 
 *
 * Assumes that you are providing at least the SELECT and FROM portions 
 * of the query. 
 *
 * The intention behind these classes is to have a query that can safely
 * be passed between methods and objects that add to it without knowledge
 * of what other methods/objects have done to it. It also means being able
 * to build a complex query without worrying about correct syntax placement.
 * 
 * ProcessWire 2.x 
 * Copyright (C) 2011 by <NAME> 
 * Licensed under GNU/GPL v2, see LICENSE.TXT
 * 
 * http://www.processwire.com
 * http://www.ryancramer.com
 *
 */
class DatabaseQuerySelectFulltext extends Wire {

	const maxQueryValueLength = 50; 

	protected $query; 

	static $scoreFields = array();

	public function __construct(DatabaseQuerySelect $query) {
		$this->query = $query; 
	}

	/**
	 * Escape string for use in a MySQL LIKE
 	 *
	 */
	protected function escapeLIKE($str) {
		return preg_replace('/([%_])/', '\\\$1', $str); 
	}

	public function match($tableName, $fieldName, $operator, $value) {

		$database = $this->wire('database');
		$query = $this->query; 
		$value = substr(trim($value), 0, self::maxQueryValueLength); <commit_msg>Update the max query value length to 500 for text fields using fulltext indexes.<commit_after><?php

/**
 * ProcessWire DatabaseQuerySelectFulltext
 *
 * A wrapper for SELECT SQL queries using FULLTEXT indexes
 * 
 * Decorates a DatabaseQuerySelect object by providing the WHERE and 
 * ORDER parts for a fulltext query based on the table, field, operator 
 * and value you are searching. 
 *
 * Assumes that you are providing at least the SELECT and FROM portions 
 * of the query. 
 *
 * The intention behind these classes is to have a query that can safely
 * be passed between methods and objects that add to it without knowledge
 * of what other methods/objects have done to it. It also means being able
 * to build a complex query without worrying about correct syntax placement.
 * 
 * ProcessWire 2.x 
 * Copyright (C) 2011 by <NAME> 
 * Licensed under GNU/GPL v2, see LICENSE.TXT
 * 
 * http://www.processwire.com
 * http://www.ryancramer.com
 *
 */
class DatabaseQuerySelectFulltext extends Wire {

	const maxQueryValueLength = 500; 

	protected $query; 

	static $scoreFields = array();

	public function __construct(DatabaseQuerySelect $query) {
		$this->query = $query; 
	}

	/**
	 * Escape string for use in a MySQL LIKE
 	 *
	 */
	protected function escapeLIKE($str) {
		return preg_replace('/([%_])/', '\\\$1', $str); 
	}

	public function match($tableName, $fieldName, $operator, $value) {

		$database = $this->wire('database');
		$query = $this->query; 
		$value = substr(trim($value), 0, self::maxQueryValueLength); 
{'fraction_non_alphanumeric': 0.10019973368841545, 'fraction_numerical': 0.007989347536617843, 'mean_word_length': 3.792663476874003, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '400847', 'n_tokens_mistral': 925, 'n_tokens_neox': 827, 'n_words': 341}