$score
$score : double
This is the score of this document. Only populated on resultset documents, of course.
This class encapsulates a single indexer document. It is used for both indexing and retrieval.
A document consists of a number of fields, each field has different properties when handled by the indexer (exact behavior depends, as always, on the indexer backend in use). On retrieval, this field information is lost, all fields being of the same type (naturally). The core indexer backend supports these field types:
This class should not be instantiated directly, a new instance of this class can be obtained using the midcom_services_indexer class.
A number of predefined fields are available using member fields. These fields are all meta-fields. See their individual documentation for details. All fields are mandatory unless mentioned otherwise explicitly and, as always, assumed to be in the local charset.
Remember, that both date and unstored fields are not available on retrieval. For the core fields, all timestamps are stored twice therefore, once as searchable field, and once as readable timestamp.
The class will automatically pass all data to the i18n charset conversion functions, thus you work using your site's charset like usual. UTF-8 conversion is done implicitly.
$creator : \midcom_db_person
The MidgardPerson who created the object.
This is optional.
$editor : \midcom_db_person
The MidgardPerson who modified the object the last time.
This is optional.
$topic_url : string
The full path to the topic that houses the document.
For external resources, this should be either a MidCOM topic, to which this resource is associated or some "directory" after which you could filter. You may also leave it empty prohibiting it to appear on any topic-specific search.
The value should be fully qualified, as returned by MIDCOM_NAV_FULLURL, including a trailing slash, f.x. https://host/path/to/topic/
This is optional.
$_i18n : \midcom_services_i18n
The i18n service, used for charset conversion.
get_field_record(string $name) : Array
Returns the complete internal field record, including type and UTF-8 encoded content.
This should normally not be used from the outside, it is geared towards the indexer backends, which need the full field information on indexing.
string | $name | The name of the field. |
The full content record.
add_date(string $name, integer $timestamp)
Add a date field. A timestamp is expected, which is automatically converted to a suitable ISO timestamp before storage.
Direct specification of the ISO timestamp is not yet possible due to lacking validation outside the timestamp range.
If a field of the same name is already present, it is overwritten silently.
string | $name | The field's name. |
integer | $timestamp | The timestamp to store. |
add_date_pair(string $name, integer $timestamp)
Create a normal date field and an unindexed _TS-postfixed timestamp field at the same time.
This is useful because the date fields are not in a readable format, it can't even be determined that they were a date in the first place. so the _TS field is quite useful if you need the original value for the timestamp.
string | $name | The field's name, "_TS" is appended for the plain-timestamp field. |
integer | $timestamp | The timestamp to store. |
add_result(string $name, string $content)
Add a search result field, this should normally not be done manually, the indexer will call this function when creating a document out of a search result.
string | $name | The field's name. |
string | $content | The field's content, which is assumed to be UTF-8 already |
html2text(string $text) : string
Convert HTML to plain text (relatively simple):
Basically, JavaScript blocks and HTML Tags are stripped, and all HTML Entities are converted to their native equivalents.
Don't replace with an empty string but with a space, so that constructs like
string | $text | The text to convert to text |
The converted text.
is_a(string $document_type) : boolean
Checks whether the given document is an instance of given document type.
This is equivalent to the is_a object hierarchy check, except that it works with MidCOM documents.
string | $document_type | The base type to search for. |
Indicating relationship.
_add_field(string $name, string $type, string $content, boolean $is_utf8 = false)
Internal helper which actually stores a field.
string | $name | The field's name. |
string | $type | The field's type. |
string | $content | The field's content. |
boolean | $is_utf8 | Set this to true explicitly, to override charset conversion and assume $content is UTF-8 already. |
add_person(string $name, \midcom_db_person $person)
Add a person field.
string | $name | The field's name. |
\midcom_db_person | $person | The field's content. |
read_person(string $id) : \midcom_db_person
Get person by given ID, caches results.
string | $id | GUID or ID to get person for |
object