esearch

ESearch provides an action and some default views for search and order by relevance in MySQL without FULLTEXT.
20 followers

Introduction

ESearch provides an action and some default views for search and order by relevance in MySQL without FULLTEXT.

Download

Download Last release

Documentation

Requirements

  • Yii 1.0 or above
  • MySQL 5.0 or above
  • PHP 5.2

Installation

  • Extract the release file under protected/extensions/esearch

Usage

//controllers/SiteController.php
 
    public function actions(){
        return array(
            // ...
            'search'=>array(
                            'class'=>'ext.esearch.SearchAction',
                            'model'=>'Post',
                            'attributes'=>array('title', 'tags', 'content'),
                        )
        );
    }
//views/layout/main.php
    $this->widget('ext.search.SearchBoxPortlet');
//or
    SearchAction::renderInputBox();
//or
    $this->renderPartial('extensions/esearch/views/inputBox.php');
'import'=>array(
        // ...
        'ext.esearch.*',
),

Resources

Total 8 comments

#11963 report it
Kreshnik Arapi at 2013/02/15 02:01pm
hello!

Excuse me but I am new to yii, can anybody tell me where exactly to put

$this->widget('ext.search.SearchBoxPortlet');
//or
    SearchAction::renderInputBox();
//or
    $this->renderPartial('extensions/esearch/views/inputBox.php');
#8051 report it
CGeorge at 2012/05/06 07:20am
Re: Fix for PHP 5.2

thanks Jazz, I just commited it!

#8029 report it
Jazz at 2012/05/04 12:02pm
Fix for PHP 5.2

Please note that PHP 5.3 is required for this extension.

To fix it for PHP 5.2 find line #49 in SearchAction.php file:

public $urlExpression = 'array(lcfirst(get_class($result))."/view", "id"=>$result->id)';

and replace it with:

public $urlExpression = 'array(strtolower(substr(get_class($result),0,1)).substr(get_class($result),1)."/view", "id"=>$result->id)';

p.s. CGeorge please add "PHP 5.3" to "Requirements" section or add this fix to new release. thanks.

#7617 report it
CGeorge at 2012/04/03 10:13am
Re: Nice work!

thanks b3atb0x, I just commited it!

#7616 report it
b3atb0x at 2012/04/03 08:37am
Nice work!

Hey man, thank you - helped to save a lot of time. I had to add one tiny fix so searching by related models would work also:

class SearchAction extends CAction {
   ...
   public $with=array();
   ...
   public function init() {
   ...
   $conditions = new CDbCriteria();
   // fix search by related:
   if($this->with) {
    $conditions->with = $this->with;
   }

After that specify 'with' parameter for that action in your controller

#4377 report it
CGeorge at 2011/07/01 08:53pm
bugs fixed & relevance

Thank you, arash, I just submited your changes to github! https://github.com/jorgebg/yii-esearch/issues/3

abajja, you can find an explanation at: http://r937.com/keyword_relevance.html

#4343 report it
arash at 2011/06/27 03:42pm
minor bugs
  1. $_qsw must be defiend in SearchAction (you just used it for stopWords)

  2. in SearchBoxPortlet, any use of $htmlOptions in init() should change with $this->htmlOptions

  3. change "" with '' in $orders[] definition (SearchAction:129) to make extension also compatible with Postgresql. final code will be like this:

$weight . '*(length(' . $attribute . ')-length(replace(' . $attribute . ',' . $searchtermTag . ',\'\')))/length(' . $searchtermTag . ')';
#4338 report it
abajja at 2011/06/27 11:58am
relevance

can you please explain whaht achieves this calculation:

$weight . '*(length(' . $attribute . ')-length(replace(' . $attribute . ',' . $searchtermTag . ',"")))/length(' . $searchtermTag . ')'

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet