- (fromarea and place.centroid is not null and not isaddress
- and (place.address is null or avals(name) && avals(place.address))
- and ST_Contains(geometry, place.centroid)) desc,
- isaddress desc, fromarea desc,
- distance asc, rank_search desc
+ (CASE WHEN coalesce((avals(name) && avals(place.address)), False) THEN 2
+ WHEN isaddress THEN 0
+ WHEN fromarea
+ and place.centroid is not null
+ and ST_Contains(geometry, place.centroid) THEN 1
+ ELSE -1 END) desc,
+ fromarea desc, distance asc, rank_search desc