Lines Matching full:page
24 * Manages the page search index by delegating to Collection classes.
93 * @return string[] list of page names (keys are the RIDs in the page index)
97 $pageIndex = new MemoryIndex('page');
105 * Check if a page needs (re-)indexing
107 * @param string $page
111 public function needsIndexing(string $page, bool $force = false): bool argument
113 $idxtag = metaFN($page, '.indexed');
118 // the index tag is written when the page is indexed; the page only needs
122 return $last < @filemtime(wikiFN($page));
126 * Add/update the search index for a page
130 * @param string $page The page to index
133 * @return bool true if the page was indexed, false if there was nothing to do
138 public function addPage(string $page, bool $force = false): bool argument
140 if (!$this->needsIndexing($page, $force)) {
141 $this->log("Indexer: index for $page up to date");
145 // create shared writable page index early so we can resolve the PID for plugins
146 $pageIndex = new FileIndex('page', '', true);
150 'page' => $page,
153 'title' => p_get_metadata($page, 'title', METADATA_RENDER_UNLIMITED),
155 p_get_metadata($page, 'relation references', METADATA_RENDER_UNLIMITED) ?? []
158 p_get_metadata($page, 'relation media', METADATA_RENDER_UNLIMITED) ?? []
160 … 'internal_index' => p_get_metadata($page, 'internal index', METADATA_RENDER_UNLIMITED) !== false,
162 'pid' => $pageIndex->accessCachedValue($page),
168 $data['body'] = $data['body'] . ' ' . rawWiki($data['page']);
175 ->addEntity($data['page'], [$data['metadata']['title']])->unlock();
181 … (new PageFulltextCollection($pageIndex))->lock()->addEntity($data['page'], $words)->unlock();
183 $this->log("Indexer: full text indexing disabled for {$data['page']}");
185 … (new PageFulltextCollection($pageIndex))->lock()->addEntity($data['page'], [])->unlock();
194 … (new PageMetaCollection($key, $pageIndex))->lock()->addEntity($data['page'], $values)->unlock();
201 io_saveFile(metaFN($data['page'], '.indexed'), $this->getVersion());
202 $this->log("Indexer: finished indexing {$data['page']}");
207 * Remove a page from the index
209 * Clears the page's data from all collections. The entity persists in page.idx.
211 * @param string $page The page to remove
214 * @return bool true if the page was removed, false if there was nothing to do
219 public function deletePage(string $page, bool $force = false): bool argument
221 $idxtag = metaFN($page, '.indexed');
223 $this->log("Indexer: $page.indexed file does not exist, ignoring");
227 $pageIndex = new FileIndex('page', '', true);
229 (new PageTitleCollection($pageIndex))->lock()->addEntity($page, [])->unlock();
230 (new PageFulltextCollection($pageIndex))->lock()->addEntity($page, [])->unlock();
233 (new PageMetaCollection($key, $pageIndex))->lock()->addEntity($page, [])->unlock();
236 $this->log("Indexer: deleted $page from index");
242 * Rename a page in the search index
244 * This renames the page's entity entry in place: its entity ID (the row in the
245 * page index) is kept and only its name is changed. Because every collection
250 * In particular this keeps the renamed page's *outgoing* references intact. That is
251 * essential during multi-step operations such as namespace moves: a page renamed
253 * later. Re-indexing from disk instead would lose this, because the destination page
256 * @param string $oldpage The old page name
257 * @param string $newpage The new page name
259 * @return bool true if the page was renamed, false if there was nothing to do
268 $pageIndex = new FileIndex('page', '', true);
279 // nothing to rename if the old page was never indexed
287 // deletePage() intentionally keeps the entity row in page.idx, so we additionally
305 * Clear all page indexes
311 Lock::acquire('page');
330 // clear title and page indexes
332 @unlink($conf['indexdir'] . '/page.idx');
335 Lock::release('page');