问题描述:

I’m working on search engine which is developed on cakephp 1.3 and full text API sphinxsearch. The search displays the results of two type or records. 1) Classes and 2) appointments. We had two different tables which creates two types of indexes. The classes and appointments data were called from model like this,

$data1 = $this-> Class-> find(array(….))

$data2 = $this->Appointment-> find(array(….))

Challenge

This data from above statement is not unified and we were facing problem in pagination because of separate handling of indexes. Remember that in cakephp, we have to create a model for using active records on that table.

Solution

For the resolution of above problem, I created a new index name “Alpha” which returns unified data of Classes and appointments. I checked from shell, it is displaying expected result.

Problem

Now the problem arouse here at this position, I have to use Alpha index in my application, I created a model for alpha but there is no table present for this model. If I do this

 $data2 = $this->Alpha->find(array(….))

It tries to search on alpha table.

If I try to find data using Class model on index alpha, it only returns the rows of class table and neglecting rows of appointment table.

$sphinx['index'] = array('users');

$practitioners = $this-> Class ->find('all', array(….));

I also tried to search data from previous model class like this but it does not work. It does not paginate multiple models.

$sphinx['index'] = array('class','appointments');

$practitioners = $this-> Class ->find('all', array($sphinx….));

I don’t know how to give alpha model reference of sphinx index ‘Alpha’.

It seems like it is framework limitation. Please guide me if I’m doing something wrong. Alternate solutions will be appreciated.

相关阅读:
Top