Reference documentation and code samples for the Cloud Bigtable Client class KeyFilter.
A builder used to configure row key related filters.
Example:
use Google\Cloud\Bigtable\Filter;
$builder = Filter::key();
Namespace
Google \ Cloud \ Bigtable \ Filter \ Builder
Methods
regex
Matches only cells from rows whose keys satisfy the given
RE2 regex. In other words,
passes through the entire row when the key matches, and otherwise
produces an empty row. Note that, since row keys can contain arbitrary
bytes, the \C escape sequence must be used if a true wildcard is
desired. The . character will not match the new line character \n,
which may be present in a binary key.
Example:
$keyFilter = $builder->regex('prefix.*');
Parameter
Name
Description
value
string
A regex value.
Returns
Type
Description
Google\Cloud\Bigtable\Filter\SimpleFilter
exactMatch
Matches only cells from rows whose keys equal the value. In other words,
passes through the entire row when the key matches, and otherwise
produces an empty row.
Example:
$keyFilter = $builder->exactMatch('r1');
Parameter
Name
Description
value
array|string
An exact value.
Returns
Type
Description
Google\Cloud\Bigtable\Filter\SimpleFilter
sample
Matches all cells from a row with probability, and matches no cells
from the row with probability 1-probability.
Example:
$keyFilter = $builder->sample(.7);
Parameter
Name
Description
probability
float
The probability to filter by. Must be within
the range [0, 1], end points excluded.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Bigtable Client - Class KeyFilter (2.17.1)\n\nVersion latestkeyboard_arrow_down\n\n- [2.17.1 (latest)](/php/docs/reference/cloud-bigtable/latest/Filter.Builder.KeyFilter)\n- [2.17.0](/php/docs/reference/cloud-bigtable/2.17.0/Filter.Builder.KeyFilter)\n- [2.16.0](/php/docs/reference/cloud-bigtable/2.16.0/Filter.Builder.KeyFilter)\n- [2.15.0](/php/docs/reference/cloud-bigtable/2.15.0/Filter.Builder.KeyFilter)\n- [2.14.0](/php/docs/reference/cloud-bigtable/2.14.0/Filter.Builder.KeyFilter)\n- [2.13.0](/php/docs/reference/cloud-bigtable/2.13.0/Filter.Builder.KeyFilter)\n- [2.12.0](/php/docs/reference/cloud-bigtable/2.12.0/Filter.Builder.KeyFilter)\n- [2.11.1](/php/docs/reference/cloud-bigtable/2.11.1/Filter.Builder.KeyFilter)\n- [2.9.1](/php/docs/reference/cloud-bigtable/2.9.1/Filter.Builder.KeyFilter)\n- [2.8.0](/php/docs/reference/cloud-bigtable/2.8.0/Filter.Builder.KeyFilter)\n- [2.7.0](/php/docs/reference/cloud-bigtable/2.7.0/Filter.Builder.KeyFilter)\n- [2.6.3](/php/docs/reference/cloud-bigtable/2.6.3/Filter.Builder.KeyFilter)\n- [2.5.0](/php/docs/reference/cloud-bigtable/2.5.0/Filter.Builder.KeyFilter)\n- [2.4.0](/php/docs/reference/cloud-bigtable/2.4.0/Filter.Builder.KeyFilter)\n- [2.3.0](/php/docs/reference/cloud-bigtable/2.3.0/Filter.Builder.KeyFilter)\n- [2.2.1](/php/docs/reference/cloud-bigtable/2.2.1/Filter.Builder.KeyFilter)\n- [2.1.0](/php/docs/reference/cloud-bigtable/2.1.0/Filter.Builder.KeyFilter)\n- [2.0.1](/php/docs/reference/cloud-bigtable/2.0.1/Filter.Builder.KeyFilter)\n- [1.32.1](/php/docs/reference/cloud-bigtable/1.32.1/Filter.Builder.KeyFilter)\n- [1.31.1](/php/docs/reference/cloud-bigtable/1.31.1/Filter.Builder.KeyFilter)\n- [1.30.0](/php/docs/reference/cloud-bigtable/1.30.0/Filter.Builder.KeyFilter)\n- [1.29.2](/php/docs/reference/cloud-bigtable/1.29.2/Filter.Builder.KeyFilter)\n- [1.28.3](/php/docs/reference/cloud-bigtable/1.28.3/Filter.Builder.KeyFilter)\n- [1.27.0](/php/docs/reference/cloud-bigtable/1.27.0/Filter.Builder.KeyFilter)\n- [1.26.2](/php/docs/reference/cloud-bigtable/1.26.2/Filter.Builder.KeyFilter)\n- [1.25.0](/php/docs/reference/cloud-bigtable/1.25.0/Filter.Builder.KeyFilter)\n- [1.24.1](/php/docs/reference/cloud-bigtable/1.24.1/Filter.Builder.KeyFilter)\n- [1.23.0](/php/docs/reference/cloud-bigtable/1.23.0/Filter.Builder.KeyFilter)\n- [1.22.2](/php/docs/reference/cloud-bigtable/1.22.2/Filter.Builder.KeyFilter)\n- [1.21.1](/php/docs/reference/cloud-bigtable/1.21.1/Filter.Builder.KeyFilter)\n- [1.20.3](/php/docs/reference/cloud-bigtable/1.20.3/Filter.Builder.KeyFilter) \nReference documentation and code samples for the Cloud Bigtable Client class KeyFilter.\n\nA builder used to configure row key related filters.\n\nExample: \n\n use Google\\Cloud\\Bigtable\\Filter;\n\n $builder = Filter::key();\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Bigtable \\\\ Filter \\\\ Builder\n\nMethods\n-------\n\n### regex\n\nMatches only cells from rows whose keys satisfy the given\n[RE2 regex](https://github.com/google/re2/wiki/Syntax). In other words,\npasses through the entire row when the key matches, and otherwise\nproduces an empty row. Note that, since row keys can contain arbitrary\nbytes, the `\\C` escape sequence must be used if a true wildcard is\ndesired. The `.` character will not match the new line character `\\n`,\nwhich may be present in a binary key.\n\nExample: \n\n $keyFilter = $builder-\u003eregex('prefix.*');\n\n### exactMatch\n\nMatches only cells from rows whose keys equal the value. In other words,\npasses through the entire row when the key matches, and otherwise\nproduces an empty row.\n\nExample: \n\n $keyFilter = $builder-\u003eexactMatch('r1');\n\n### sample\n\nMatches all cells from a row with `probability`, and matches no cells\nfrom the row with probability 1-`probability`.\n\nExample: \n\n $keyFilter = $builder-\u003esample(.7);"]]