@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3/**
4 * Base class for Phabricator search engine providers. Each engine must offer
5 * three capabilities: indexing, searching, and reconstruction (this can be
6 * stubbed out if an engine can't reasonably do it, it is used for debugging).
7 */
8abstract class PhabricatorFulltextStorageEngine extends Phobject {
9
10 protected $service;
11
12 public function getHosts() {
13 return $this->service->getHosts();
14 }
15
16 public function setService(PhabricatorSearchService $service) {
17 $this->service = $service;
18 return $this;
19 }
20
21 /**
22 * @return PhabricatorSearchService
23 */
24 public function getService() {
25 return $this->service;
26 }
27
28 /**
29 * Implementations must return a prototype host instance which is cloned
30 * by the PhabricatorSearchService infrastructure to configure each engine.
31 * @return PhabricatorSearchHost
32 */
33 abstract public function getHostType();
34
35/* -( Engine Metadata )---------------------------------------------------- */
36
37 /**
38 * Return a unique, nonempty string which identifies this storage engine.
39 *
40 * @return string Unique string for this engine, max length 32.
41 * @task meta
42 */
43 abstract public function getEngineIdentifier();
44
45/* -( Managing Documents )------------------------------------------------- */
46
47 /**
48 * Update the index for an abstract document.
49 *
50 * @param PhabricatorSearchAbstractDocument $document Document to update.
51 * @return void
52 */
53 abstract public function reindexAbstractDocument(
54 PhabricatorSearchAbstractDocument $document);
55
56 /**
57 * Execute a search query.
58 *
59 * @param PhabricatorSavedQuery $query A query to execute.
60 * @return list A list of matching PHIDs.
61 */
62 abstract public function executeSearch(PhabricatorSavedQuery $query);
63
64 /**
65 * Does the search index exist?
66 *
67 * @return bool
68 */
69 abstract public function indexExists();
70
71 /**
72 * Implementations should override this method to return a dictionary of
73 * stats which are suitable for display in the admin UI.
74 */
75 abstract public function getIndexStats();
76
77
78 /**
79 * Is the index in a usable state?
80 *
81 * @return bool
82 */
83 public function indexIsSane() {
84 return $this->indexExists();
85 }
86
87 /**
88 * Do any sort of setup for the search index.
89 *
90 * @return void
91 */
92 public function initIndex() {}
93
94
95 public function getFulltextTokens() {
96 return array();
97 }
98
99}