Search System Specification - NFSandbox/sh_trade_backend GitHub Wiki
Search Item
- Item Name
- Item Description
Search Tags
- Union Several Tags
Search User
- Tag-Centered Searching
Result consists of two part:
- Item metadata related result
- Tag related result.
- Ranked by satisfied tags count
The search result should contains several part:
- Item Search result using Item Name Search.
- Item Search result using Tag List Search.
- Tag Search result.
To be simple, we could directly use name LIKE %{search_name}% to select items.
Consider user provided a list of tag string:
[tag1, tag2, tag3, ...]
The ranking criteria could be the number of tags a certain item have that is included in the tag list.
We could select Tag entity with Item entity joined, grouped by Item.item_id. This means the count of one group is exactly how many tags of an item has matched the tag list. (In case that Item.tag not duplicated)
Then we can order the select result by the group count.
We should consider support Search Filter format in keyword at backend-level.
The basic format of filter should be:
<filter_keyword>:[<filter_value>]
The filter_keyword is compulsory while filter_value part could be left empty.
There could be several filters in one search string query, and all filters would be first converted into a filter info dictionary.
The String-To-Dict conversion should be implemented in backend, which ensures we don’t need to rewrite the conversion logic across different frontend programs.
Below is an example of such format:
Test Item recent:14 processing: tag:a tag:b
Should be first converted into:
filter_dict = {
recent: 14,
processing: true,
tag:[a, b]
}recent filter is used to limited the published time of the item in search result. The <number> value is used to specify the limit time period in day unit.
E.g.: recent:7 will limit the items is published in recent 7 days.
tag filter is used to specify the tags an item must have to appeared in the search result. Items does not contain the specified tags will be filtered out of the search result.
Note that you can add several tag filters in a single search query, in this case all tags specified should be required on an item (connected with AND criteria when perform database queries).
E.g.: chairs tag:wood tag:ikea will return items with keyword chairs in name and with both wood and ikea tags.
-
Item:Nice chairs tags=[wood, new] -
Item:Ordinary chairs tags=[wood, ikea] -
Item:Ordinary chairs tags=[wood, ikea, new] -
Item:chair tags=[]
All functionalities of filters should finally be able to interpreted as a WHERE criteria of a SQL Statement. The process detail is as follows:

As the image shows, we should also promise the WHERE criteria produced by filters does not interfere with the one generated by by-name and by-tag searches which will cause incorrect result.