/** * remove the index of the property. * @throws Exception * @return void */ public function removePropertyIndex() { if (!tao_helpers_Request::isAjax()) { throw new Exception("wrong request mode"); } if (!$this->hasRequestParameter('uri')) { throw new common_exception_MissingParameter("Uri parameter is missing"); } if (!$this->hasRequestParameter('indexProperty')) { throw new common_exception_MissingParameter("indexProperty parameter is missing"); } $indexPropertyUri = tao_helpers_Uri::decode($this->getRequestParameter('indexProperty')); //remove use of index property in property $property = new core_kernel_classes_Property(tao_helpers_Uri::decode($this->getRequestParameter('uri'))); $property->removePropertyValue(new core_kernel_classes_Property(INDEX_PROPERTY), $indexPropertyUri); //remove index property $indexProperty = new \oat\tao\model\search\Index($indexPropertyUri); $indexProperty->delete(); echo json_encode(array('id' => $this->getRequestParameter('indexProperty'))); }
public function getSolrId(Index $index) { if (!isset($this->map[$index->getIdentifier()])) { $suffix = $index->isFuzzyMatching() ? '_t' : '_s'; if ($index->isDefaultSearchable()) { $suffix .= '_d'; } $this->map[$index->getIdentifier()] = $index->getIdentifier() . $suffix; } return $this->map[$index->getIdentifier()]; }
protected function indexProperty(Document $document, \core_kernel_classes_Property $property) { $indexes = $property->getPropertyValues(new \core_kernel_classes_Property('http://www.tao.lu/Ontologies/TAO.rdf#PropertyIndex')); foreach ($indexes as $indexUri) { $index = new Index($indexUri); $id = $index->getIdentifier(); $strings = $index->tokenize($this->resource->getPropertyValues($property)); if (!empty($strings)) { if ($index->isFuzzyMatching()) { // cannot store multiple fuzzy strings $string = implode(' ', $strings); $field = Document\Field::Text($index->getIdentifier(), $string); $field->isStored = $index->isStored(); $document->addField($field); } else { $value = count($strings) > 1 ? $strings : reset($strings); $field = Document\Field::Keyword($index->getIdentifier(), $value); $field->isStored = $index->isStored() && !is_array($value); // storage of arrays not supported $document->addField($field); } } } }