-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem Statement
pg_textsearch supports ranking results via the <@> operator in ORDER BY clauses. However, because the amproperty hook is not implemented to handle AMPROP_DISTANCE_ORDERABLE, Postgres core metadata logic returns NULL (Unknown) when inspecting this index property:
pg_textsearch/src/am/handler.c
Line 74 in 53c50c2
| amroutine->amproperty = NULL; /* No property function */ |
create table document (content text);
create index bm25_index on document using bm25 (content) with (text_config = 'english');
select pg_index_column_has_property('bm25_index'::regclass, 1, 'distance_orderable');
pg_index_column_has_property
------------------------------
(1 row)Proposed Solution
Implement amproperty():
bool
tp_property(Oid index_oid, int attno,
IndexAMProperty prop, const char *propname,
bool *res, bool *isnull)
{
/* Only handle column-level properties */
if (OidIsValid(index_oid) && attno > 0)
{
switch (prop)
{
case AMPROP_DISTANCE_ORDERABLE:
*res = true;
*isnull = false;
return true;
default: /* Do not override other properties' impl */
}
}
/* use Postgres's default logic */
return false;
}Alternatives Considered
None
Additional Context
It is recommended (see the amproperty() section) to implement this:
Access methods that support ordering operators should implement AMPROP_DISTANCE_ORDERABLE property testing, as the core code does not know how to do that and will return NULL.
But it is actually ok to not do this as omitting it won't prevent queries from running.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request