1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <?php
use Ivory\LuceneSearchBundle\Model\Document;
use Ivory\LuceneSearchBundle\Model\Field;
// Request an index
$index = $this->get('ivory_lucene_search')->getIndex('identifier');
// Create a new document
$document = new Document();
$document->addField(Field::keyword('field1', 'Keyword'));
$document->addField(Field::text('field2', 'Some text'));
// Add your document to the index
$index->addDocument($document);
// Commit your change
$index->commit();
// If you want you can optimize your index
$index->optimize(); |
Partager