frontend
frontend copied to clipboard
Prioritize exchanges in search results
Goal
Include relevant exchanges towards the top of search results in Advanced Search.
Background
Currently when using Advanced Search to search for an exchange-specific term such as "pancakeswap", the matching exchange is not displayed in the search results. Although the PancakeSwap exchanges have a high relevance score, they are ranked to the bottom of the search results due to the default sort option ▼ Liquidity
(exchanges have a null
value for liquidity
).
Possible Solution
Typesense has a new feature that can potentially help address this: Sorting null, empty or missing values
To make use of this feature, the sort value for the ▼ Liquidity
option in SortSelect.svelte should be updated to:
['liquidity(missing_values:first):desc', '_text_match:desc']
This change addresses the pancakeswap
example, but causes a new search rank issue.
With this change in place, PancakeSwap exchanges are ranked to the top as desired. However, updating the search query to "eth" reveals a different problem.
Currently, all Uniswap V3 trading pairs have a null
value for liquidity
. With the missing_values:first
sort option applied, these trading pairs are sorted to the top (ahead of other pairs with high liquidity
) when they match the query term. This seems undesirable and inconsistent with the ▼ Liquidity
sort order.
Consideratoins
What we need is a way to prioritize exchanges in the search rank without affecting other trading entities (tokens, pairs).
The search index already includes a type_rank
field (used for sorting the grouped results on top-nav search) with the following values:
- exchange = 1
- pair = 3
- token = 4
This doesn't exactly serve our needs because we don't want to prioritize pairs over tokens in ▼ Liquidity
sorted searches. It seems confusing to add yet another "special case" rank field to the index.
Next steps
Experiment some more with Typesense options and ask for advice on the Typesense slack channel.