public static function createFromLegacyField(databox_field $field) { $type = self::getTypeFromLegacy($field); $databox = $field->get_databox(); // Thesaurus concept inference $xpath = $field->get_tbranch(); if ($type === Mapping::TYPE_STRING && !empty($xpath)) { $roots = ThesaurusHelper::findConceptsByXPath($databox, $xpath); } else { $roots = null; } // Facet (enable + optional limit) $facet = $field->getFacetValuesLimit(); if ($facet === databox_field::FACET_DISABLED) { $facet = self::FACET_DISABLED; } elseif ($facet === databox_field::FACET_NO_LIMIT) { $facet = self::FACET_NO_LIMIT; } return new self($field->get_name(), $type, ['searchable' => $field->is_indexable(), 'private' => $field->isBusiness(), 'facet' => $facet, 'thesaurus_roots' => $roots, 'used_by_collections' => $databox->get_collection_unique_ids()]); }
public function populateIndex(BulkOperation $bulk, array $databoxes) { foreach ($databoxes as $databox) { /** @var databox $databox */ $databoxId = $databox->get_sbas_id(); $visitor = new TermVisitor(function ($term) use($bulk, $databoxId) { // Path and id are prefixed with a databox identifier to not // collide with other databoxes terms // Term structure $id = sprintf('%s_%s', $databoxId, $term['id']); unset($term['id']); $term['path'] = sprintf('/%s%s', $databoxId, $term['path']); $term['databox_id'] = $databoxId; // Index request $params = array(); $params['id'] = $id; $params['type'] = self::TYPE_NAME; $params['body'] = $term; $bulk->index($params, null); }); $document = Helper::thesaurusFromDatabox($databox); $this->navigator->walk($document, $visitor); } }
private function ensureDocumentLoaded() { if (!$this->document) { $this->document = Helper::candidatesFromDatabox($this->databox); } }
public function visitConcept(DOMElement $element) { array_push($this->path, Helper::conceptPathSegment($element)); }