<p>I am looking for information on handling search in different ORMs.</p>

<p>Currently I am redeveloping some old application in PHP and one of requirements is: make everything or almost everything searchable, so user just types "punkrock live" and the app finds videos clips, music tracks, reviews, upcoming events or even user comments labeled that way.</p>

<p>In environment where everything is searchable ORM need to support this feature in two ways:</p>

<ul>
<li>providing some indexing API on "O" side of ORM</li>
<li>providing means for bulk database retrieval on "R" side</li>
</ul>

<p>Ideal solution would return ready made objects based on searched string.
Do you know any good end-to-end solutions that does the job, not necessarily in PHP?
If you dealt with similar problem it would be nice to listen what your experience is. Something more than <em>Use Lucene</em> or <em>semantic web is the way</em> oneliners, tho ;-)*</p>

[{'answer_id': 22745, 'author': 'Martin Klinke', 'author_id': 1793, 'author_profile': 'https://Stackoverflow.com/users/1793', 'pm_score': 3, 'selected': True, 'text': '<p>I have recently integrated the <a href="http://www.compass-project.org/" rel="nofollow noreferrer">Compass</a> search engine into a Java EE 5 application. It is based on <a href="http://lucene.apache.org/java/docs/index.html" rel="nofollow noreferrer">Lucene Java</a> and supports different ORM frameworks as well as other types of models like XML or no real model at all ;)</p>\n\n<p>In the case of an object model managed by an ORM framework you can annotate your classes with special annotations (e.g. @Searchable), register your classes and let Compass index them on application startup and listen to changes to the model automatically.</p>\n\n<p>When it comes to searching, you have the power of Lucene at hand. Compass then gives you instances of your model objects as search result.</p>\n\n<p>It\'s not PHP, but you said it didn\'t have to be PHP necessarily ;) Don\'t know if this helps, though...</p>\n'}, {'answer_id': 302878, 'author': 'lo_fye', 'author_id': 3407, 'author_profile': 'https://Stackoverflow.com/users/3407', 'pm_score': 1, 'selected': False, 'text': '<p>In a Propel 1.3 schema.xml file, you can specify that you\'d like all your models to extend a "BaseModel" class that YOU create.</p>\n\n<p></p>\n\n<p>In that BaseModel, you\'re going to re-define the save() method to be something like this:</p>\n\n<pre><code>public function save(PropelPDO $con = null)\n{\n    if($this-&gt;getIsSearchable())\n    {\n             // update your search index here. Lucene, Sphinx, or otherwise\n    }\n\n    return parent::save($conn);\n}\n</code></pre>\n\n<p>That takes care of keeping everything indexed. As for searching, I\'d suggest creating a Search class with a few methods.</p>\n\n<pre><code>class Search\n{\n   protected $_searchableTypes = array(\'music\',\'video\',\'blog\');\n\n   public method findAll($search_term)\n   {\n      $results = array();\n\n      foreach($this-&gt;_searchableTypes as $type)\n      {\n         $results[] = $this-&gt;findType($type, $search_term);\n      }\n\n      return $results;\n   }\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/22431', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2169/']