Search code examples
databaseriak

Modeling data for maximum searchability


What's the best way to model this data:

public class Item {
    Double price;
    String geoHash;
    Long startAvailabilty; // timestamp
    Long endAvailabilty; // timestamp
    Set<String> keywords;
    String category;
    String dateCreated; // iso date
    String dateUpdated; // iso date
    Integer likes;
    Boolean isActive;
}

As such it will be possible to query and search for the ff:

  • Price range
  • String "starts with" query (geo hash search)
  • Timestamp range (similar to price range)
  • Keyword search (search from a set of string)
  • Equality (for category etc)
  • ISO Date string search
  • Boolean search (search w/c one is active)

For the Riak KV database.


Solution

  • From the above, I can imagine this being implemented either via maps, possibly containing sets with map reduce/secondary indexes or by using Yokozuna (Solr).

    Despite this, the above data set looks more like it should be in a relational database than a non-SQL database. For something in the middle, you might want to consider Riak TS (download) which is similar to KV but has a thin SQL layer on top. The current version (1.5.1) is a bit old but we plan to launch an improved version later this year with additional SQL features available.