xref: /dokuwiki/inc/Search/Collection/LookupCollection.php (revision f2bbffb509f37291c31c023167b8aeb383079d6d)
1*f2bbffb5SAndreas Gohr<?php
2*f2bbffb5SAndreas Gohr
3*f2bbffb5SAndreas Gohrnamespace dokuwiki\Search\Collection;
4*f2bbffb5SAndreas Gohr
5*f2bbffb5SAndreas Gohr/**
6*f2bbffb5SAndreas Gohr * Abstract collection for lookup-based indexes
7*f2bbffb5SAndreas Gohr *
8*f2bbffb5SAndreas Gohr * In a lookup collection each token appears at most once per entity (frequency is always 1).
9*f2bbffb5SAndreas Gohr * Internally the same mechanisms as FrequencyCollection are used; only the way tokens are
10*f2bbffb5SAndreas Gohr * processed on input differs (deduplication instead of counting).
11*f2bbffb5SAndreas Gohr *
12*f2bbffb5SAndreas Gohr * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
13*f2bbffb5SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
14*f2bbffb5SAndreas Gohr */
15*f2bbffb5SAndreas Gohrabstract class LookupCollection extends AbstractCollection
16*f2bbffb5SAndreas Gohr{
17*f2bbffb5SAndreas Gohr    /** @inheritdoc */
18*f2bbffb5SAndreas Gohr    protected function countTokens(array $tokens): array
19*f2bbffb5SAndreas Gohr    {
20*f2bbffb5SAndreas Gohr        return array_fill_keys(array_unique($tokens), 1);
21*f2bbffb5SAndreas Gohr    }
22*f2bbffb5SAndreas Gohr}
23