Open keymastervn opened 1 year ago
I need to order using a custom distance function, so this unfortunately isn't flexible enough.
However, I found I can simply use reorder
to get rid of the pg_search ranking order and use my own order.
@futuretap I am still unclear on what your use case is, can you please provide me more context, perhaps a SQL query?
The option ranking order
may come with a hash or string. If your distance is the below distance_meters
SELECT earth_distance(
ll_to_earth(37.77492, -122.41942),
ll_to_earth(40.71278, -74.00595)
) AS distance_meters
Then the option is simply ranking_order: "distance_meters DESC"
.
In my case, I want to count the tsvector weight as well, so your change reorder
must have a way to count #{rank_table_alias}.rank
as well if I don't get wrong.
My order is using PostGIS: location <-> 'SRID=4326;POINT(11.0 48.0)'::Geometry
and I don't want to use the search rank at all.
This PR changes how the gem is ranked by default
pg_search.rank DESC
, followed up byorder_within_rank
as the tiebreaker. Now, it supports ordering by other fields BEFOREpg_search.rank
In my case, ranking is not the most important to be considered first. For instance, we have options to sort by relevance order (1) AND posted date order (2). The requirement for (2) will respect the posted date order before another matching, similar to partitioning by date and apply ranking inside the partitions.
This option
ranking_order
somehow is opposite toorder_within_rank
, please suggest me a proper name.