Let's say I am building a marketplace like eBay (or something) for example,
With a data that looks like this (pseudo-code):
public class Item {
Double price;
String geoHash;
Long startAvailabilty; // timestamp
Long endAvailabilty; // timestamp
Set<Keywords> keywords;
String category;
String dateCreated; // iso date
String dateUpdated; // iso date
Integer likes;
Boolean isActive;
}
Suppose I want to build a "query" that will filter items give the following:
Items are stored with field data (title, price, timestamp range), and also some texts (description). And then I need to filter based on the following:
- Price range (e.g. 100-200)
- Location (e.g. starts with a GeoHash prefix)
- Between given millisecond timestamp (each record have a start and end date for example) -- e.g. valid period for the item
- Has a given keyword (each record having an array of keyword preprocessed before storing)
- Has a given category
- Has a date created and date updated (which is common)
- Has a given keyword text (this one I think is not really possible, as this is a full-text search)
And I want to order the result based on the following:
- Number of likes first (each record are stored with a number of likes)
- Latest or recently created first
- Is still active (each record has a boolean value if it's active or not)
How should this be modeled/stored in a Key-Value database as such that it can be retrieved using the given query above? That is without using any schema (schemaless)