Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6765559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:43:34+00:00 2026-05-26T14:43:34+00:00

I need to create an match-finder system for some data set, as follows: There

  • 0

I need to create an match-finder system for some data set, as follows:

There is a set of objects, each identified by a string ObjectID.

Each object has exactly N properties Pi. Each property value is a string.

Database example for N = 3 (in real life N = 8).

ObjectID: P1     P2    P3
--------------------------------
APPLE:    RED    ROUND FRUIT
ORANGE:   ORANGE ROUND FRUIT
CARROT:   RED    LONG  VEGETABLE

The system must return sets of ObjectIDs, matching given query on object properties. In query user must specify all property values. Alternatively, for some or all properties in query user may specify a “wildcard” *, meaning that any property value would match criteria.

Example queries:

P1  P2    P3        => Result
------------------------------------
*   ROUND FRUIT     => APPLE, ORANGE
RED LONG  VEGETABLE => CARROT
RED *     *         => CARROT, APPLE

All of this is trivially done with SQL.

The question is: is there a neat way to do that with Redis?

Note that I’m interested in Redis-based solutions specifically, for self-education purposes; other DBs are offtopic for this particular question.

Update: Trivial solution with explicit ObjectID lists for each Pi and application-side filtering does not look neat enough to me 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:43:35+00:00Added an answer on May 26, 2026 at 2:43 pm

    What you are trying to do here is an inverted index.

    For each column, have it map to a “set”. Then, you can intersect the sets to get the result.

    So, APPLE: RED ROUND FRUIT would map to the following inserts:

    SADD p1:RED APPLE
    SADD p2:ROUND APPLE
    SADD p3:FRUIT APPLE
    

    Then, let’s say I want to query for * ROUND FRUIT, I would do:

    SINTER p2:ROUND p3:FRUIT
    

    This command is taking the intersection of the items in the p2:ROUND set and the p3:FRUIT set. This will return all the items that are ROUND and FRUIT, not caring what p1 is.

    Some other examples:

    SMEMBERS p1:GREEN
    SINTER p1:RED p2:ROUND p3:FRUIT
    SUNION p1:RED p1:GREEN
    

    My above answer is going to use some computation power because the intersection operation is O(N*M). Here is a way of doing it that is more memory intensive, but will have faster retrieval because it effectively precomputes the indexes.

    For each combination of properties, make a key that stores a set:

    So, APPLE: RED ROUND FRUIT would map to the following inserts:

    SADD RED:ROUND:FRUIT APPLE
    SADD :ROUND:FRUIT APPLE
    SADD RED::FRUIT APPLE
    SADD RED:ROUND: APPLE
    SADD RED:: APPLE
    SADD :ROUND: APPLE
    SADD ::FRUIT APPLE
    SADD ::: APPLE
    

    Then, to query, you simply access the respective key. For example, * ROUND FRUIT would simply be

    SMEMBERS :ROUND:FRUIT
    

    Obviously, this doesn’t scale well at all in terms of memory when you have many dimensions, but it will be extremely snappy to retrieve results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a regexp to match strings like this 999-123-222-...-22 The string
I need to create a regular expression to match strings that satisfy any two
I need to create a default route for my application: match '/:controller(/:action(/:id))' The thing
I need to create a dictinary where key is string and value is Object.
We need to create hidden system subfolders in every IGFolder an normal user creates.
Basically I need to create a quickfix buffer listing all lines that match a
I have two sets of data which I need to join, but there is
I need to create a regex that can match multiple strings. For example, I
Hello all, I need to create a query for house search, that would match
How do I create a random unique string in MySQL? when I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.