14 use ZendSearch\Lucene\Document;
15 use ZendSearch\Lucene\Document\Field;
40 $doc =
new Document();
43 $doc->addField(Field::keyword(
'oid', $obj->
getOID()->__toString(),
'UTF-8'));
44 $typeField = Field::keyword(
'type', $obj->
getType(),
'UTF-8');
45 $typeField->isStored =
false;
46 $doc->addField($typeField);
47 if ($language !=
null) {
48 $languageField = Field::keyword(
'lang', $language,
'UTF-8');
49 $doc->addField($languageField);
54 $allAttributes = $mapper->getAttributes();
55 $includedAttributes = array_filter($allAttributes,
function($attribute) {
56 return $attribute->hasTag(
'SEARCHABLE');
58 if (
sizeof($includedAttributes) == 0) {
59 $includedAttributes = $allAttributes;
63 foreach ($includedAttributes as $attribute) {
64 $valueName = $attribute->getName();
67 if (!is_object($value) && !is_array($value)) {
69 if (preg_match(
'/^text|^f?ckeditor/', $inputType)) {
70 $value = strip_tags($value);
71 $doc->addField(Field::unStored($valueName, $value,
'UTF-8'));
74 $field = Field::keyword($valueName, $value,
'UTF-8');
75 $field->isStored =
false;
76 $doc->addField($field);
89 if (preg_match(
'/^f?ckeditor/', $inputType)) {
90 $value = html_entity_decode($value, ENT_QUOTES,
'UTF-8');
getType()
Get the type of the object.
DefaultIndexStrategy implements indexing of PersistentObject values and might be customized by overri...
enhanceDocument(Document $doc, PersistentObject $obj, $language)
Customize the lucene document according the the application requirements.
getOID()
Get the object id of the PersistentObject.
getMapper()
Get the PersistenceMapper of the object.
getValue($name)
Get the value of an attribute.
getValueProperty($name, $property)
Get the value of one property of an attribute.
isIncluded(PersistentObject $obj, $language)
Determine whether the object is included in the index or not.
getDocument(PersistentObject $obj, $language)
IndexStrategy defines the interface for indexing implementations.
encodeValue($value, $inputType)
PersistentObject defines the interface of all persistent objects.