Changeset 6771
- Timestamp:
- 12/27/07 21:01:54 (1 year ago)
- Files:
-
- plugins/sfLucenePlugin/branches/1.1/CHANGELOG (modified) (1 diff)
- plugins/sfLucenePlugin/branches/1.1/README (modified) (4 diffs)
- plugins/sfLucenePlugin/branches/1.1/lib/indexer/sfLucenePropelIndexer.class.php (modified) (3 diffs)
- plugins/sfLucenePlugin/branches/1.1/lib/results/sfLuceneModelResult.class.php (modified) (1 diff)
- plugins/sfLucenePlugin/branches/1.1/lib/results/sfLuceneResult.class.php (modified) (1 diff)
- plugins/sfLucenePlugin/branches/1.1/test/unit/indexer/sfLucenePropelIndexerTest.php (modified) (3 diffs)
- plugins/sfLucenePlugin/branches/1.1/test/unit/results/sfLuceneResultTest.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfLucenePlugin/branches/1.1/CHANGELOG
r6657 r6771 14 14 * Upgraded forms to sfForm 15 15 * Fixed sfLucene does not handle changed categories (closes #2687) 16 * BC: Reinstated camel case for indexes. If you had "superDuperMan" in a 17 fields or categories parameter, you now *must* make the declaration 18 "super_duper_man". 16 19 17 20 Version 0.1.1 Beta plugins/sfLucenePlugin/branches/1.1/README
r6733 r6771 11 11 = Main Features = 12 12 * Configured all by YAML files 13 * Complete integration with symfony 13 * Complete integration with symfony 1.1 14 14 * i18n ready 15 15 * Keyword highlighting 16 * Stop words, short words 17 * Index optimization 18 * Custom indexers 19 * Multiple indexes 20 * Extensible 16 * Management of Lucene indexes 17 * 500+ unit tests and 98% API code coverage 21 18 22 19 = Development Status = … … 116 113 When search results are displayed, the system intelligently guesses which field should be displayed as the result "title" and which field is the result "description." However, to be explicit, you can specify a description and title field, as in BlogComment. 117 114 118 Note that the fields do not have to exist as fields in your database. As long as it has a getter on the model, you can use it in your index. 115 Note that the fields do not have to exist as fields in your database. As long as it has a getter on the model, you can use it in your index. The fields are automatically camelized, so if you wish to call "->getSuperDuperMan()" as one of your fieds, you must write it in the YAML file as "super_duper_man". 119 116 120 117 See [http://framework.zend.com/manual/en/zend.search.lucene.html the Zend_Search_Lucene documentation] for more about the field types. … … 180 177 models: 181 178 BlogPost: 182 validator: should Index179 validator: should_index 183 180 }}} 184 181 … … 404 401 The "Blog" model above will be placed both into the blog category and the string returned by ->getCategory() on the model. After you rebuild your model, a category drop down will automatically appear on the search interface. 405 402 403 The same rules applies as model indexing: Note that the fields do not have to exist as fields in your database. As long as it has a getter on the model, you can use it in your index. The fields are automatically camelized, so if you wish to call "->getSuperDuperMan()" as one of your fieds, you must write it in the YAML file as "super_duper_man". 404 406 405 To disable category support all-together, open the application level app.yml file and add: 407 406 plugins/sfLucenePlugin/branches/1.1/lib/indexer/sfLucenePropelIndexer.class.php
r6695 r6771 105 105 $field_properties = $properties->get('fields')->get($field); 106 106 107 $getter = 'get' . $field;107 $getter = 'get' . sfInflector::camelize($field); 108 108 109 109 $type = $field_properties->get('type'); … … 192 192 $properties = $this->getModelProperties(); 193 193 $method = $properties->get('validator'); 194 $method = sfInflector::camelize($method); 194 195 195 196 if ($method && method_exists($this->getModel(), $method)) … … 218 219 $category = substr($category, 1, -1); 219 220 220 $getter = 'get' . $category;221 $getter = 'get' . sfInflector::camelize($category); 221 222 222 223 $getterValue = $this->getModel()->$getter(); plugins/sfLucenePlugin/branches/1.1/lib/results/sfLuceneModelResult.class.php
r6687 r6771 51 51 if (!$model->has('route')) 52 52 { 53 throw new sfLuceneIndexerException(sprintf('A route for model "%s" was not defined in the search.yml file.', $this->getInternalModel()));53 throw new sfLuceneIndexerException(sprintf('A route for model "%s" was not defined.', $this->getInternalModel())); 54 54 } 55 55 56 return preg_replace_callback('/%(\w+?)%/', array($this, 'internalUriCallback'), $model->get('route')); 57 } 58 59 /** 60 * Callback for self::getInternalUri() 61 */ 62 protected function internalUriCallback($matches) 63 { 64 return $this->result->getDocument()->getFieldValue($matches[1]); 56 return preg_replace('/%(\w+?)%/e', '$this->result->getDocument()->getFieldValue("$1")', $model->get('route')); 65 57 } 66 58 plugins/sfLucenePlugin/branches/1.1/lib/results/sfLuceneResult.class.php
r6685 r6771 138 138 { 139 139 $property = substr($method, strlen($prefix)); 140 $property = strtolower($property);140 $property = $property; 141 141 142 if (s ubstr($property, 0, 8) == 'internal')142 if (strtolower(substr($property, 0, 8)) == 'internal') 143 143 { 144 $property = 'sfl_' . substr($property, 8); 144 $property = 'sfl_' . sfInflector::underscore(substr($property, 8)); 145 } 146 else 147 { 148 $property = sfInflector::underscore($property); 145 149 } 146 150 plugins/sfLucenePlugin/branches/1.1/test/unit/indexer/sfLucenePropelIndexerTest.php
r6696 r6771 161 161 $indexer->delete(); 162 162 $h->get('fields')->remove('nonScalar'); 163 $h->get('fields')->set('stringable Object', $ph);163 $h->get('fields')->set('stringable_object', $ph); 164 164 165 165 try { … … 167 167 $lucene->commit(); 168 168 $doc = getDoc($lucene, $indexer->getModelGuid()); 169 $t->is($doc->stringable object, 'Strings!', '->insert() converts objects to strings in field getters');169 $t->is($doc->stringable_object, 'Strings!', '->insert() converts objects to strings in field getters'); 170 170 } catch (Exception $e) { 171 171 $t->fail('->insert() converts objects to strings in field getters'); … … 346 346 } 347 347 348 $h->set('categories', array('Forum', '%stringable Object%'));348 $h->set('categories', array('Forum', '%stringable_object%')); 349 349 350 350 $indexer->delete(); plugins/sfLucenePlugin/branches/1.1/test/unit/results/sfLuceneResultTest.php
r6685 r6771 17 17 require dirname(__FILE__) . '/../../bootstrap/unit.php'; 18 18 19 $t = new lime_test(2 1, new lime_output_color());19 $t = new lime_test(23, new lime_output_color()); 20 20 21 21 $lucene = sfLucene::getInstance('testLucene'); … … 37 37 public function getFieldValue($field) 38 38 { 39 if (!isset($this->$field)) throw new Exception(' You said to');39 if (!isset($this->$field)) throw new Exception('Field ' . $field . ' does not exist'); 40 40 41 41 return $this->$field; … … 81 81 $t->is($result->getSequence(), '123', '->getXXX() returns property XXX on document'); 82 82 $t->ok($result->hasSequence(), '->hasXXX() returns true if document has property XXX'); 83 84 $doc->super_duper_man = 'Fabien Potencier'; 85 $t->is($result->getSuperDuperMan(), 'Fabien Potencier', '->getXXX() returns property XXX for camel case'); 86 $t->ok($result->hasSuperDuperMan(), '->hasXXX() returns if document has property XXX for camel case'); 83 87 84 88 try {