Sapp is a search app for the SAFE network. It will work like a search engine for the web. When using Google Search for example, in the vast majority of cases it’s only the 10 first search results that are used. Therefore, in order to simplify the Sapp index, it contains only the (up to) top 100 search results for each query.
The top 100 search results are store in MutableData objects called RSR (Ranked Search Results) with the following structure:
id = hash(query)
sreList = ordered list of up to 100 SRE ids
An SRE (Search Result Entry) is an ImmutableData object containing:
id = hash(n + ’ ’ + query), where n is a sequence number 1, 2, 3…
timestamp = millisecond UTC for when the entry was stored
url = the URL for the search result
text = text snippet for the search entry
Note that the number of possible SREs for each query is unlimited so there can be many more search engine entries than those listed in the ranked search results.
The ranked search results are pluggable so that one version of the search app can rank SREs based on user votes and another version can rank SREs with a different kind of ranking algorithm, and so on.
For Sapp to work in practice a huge number of SREs are needed. Each url can have thousands (actually millions) of possible queries and each query has its own SRE object. Also, for instance the query “new car models” has a different SRE than the query “car models new”. The idea is that data storage on the SAFE network will be inexpensive and so an enormous number of SREs can be stored in practice making Sapp feasible.
Anyone can store SREs for any kind of queries and urls, including spam and false entries. It’s up to the RSR algorithms to rank and select the SREs to produce high quality search results.