php - Simple keyword search with full match -


i need simple keyword search.

i have objects have associated set of keywords them. need way reliable search these keywords.

after search set of keywords search library should return ids of objects associated these keywords. additional need know there full match(all searched keywords presented in single set [associated object]).

i want avoid building query multiple or operators.

can point me library or tutorial how can achieve this?

as see php tag assume no db involved. list of objects state.

i don't quite know mean building query when there not db, question bit unclear.

i assume class objects talking about:

class someobject {      private $id;     private $keywords = array();      public function getid()     {         return $this->id;     }   public function getkeywords()     {         return $this->keywords;     }  } 

then solution:

function filterobjectarray($objectarray, $search) {     $resultids = array();     $resultobjects = array();     foreach ($objectarray $object)     {         foreach ($object->getkeywords() $keyword)         {             if ($search == $keyword)             {                 $resultids[] = $object->getid();                 $resultobjects[] = $object;                 break;             }         }     }      return $resultobjects;     // or return $resultids; think returning objects nicer solution. } 

now lets assume db related folowing tables:

someobject  \ id  \ name   \ etc  keywords  \ id  \ keyword  \ someobjectid 

then be:

    select  id  someobject o   exists (select 1 keywords k k.keyword = 'thekeywordiamlookingfor' , k.objectid = someobject.id) 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -