468,167 Members | 1,937 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,167 developers. It's quick & easy.

Matching Specific Ad Based On Various Filters

15
Hi, I need a little help with someting Iíd like to implement, but not sure how to do it.

Iím running eBay like classifieds site. There are a lot of filters on my site e.g. you can filter ads by price, by category, by city, by conditionÖ
Letís say we have this use case:

- User is able to filter ads on my site using filters
- Once he does it he can save those filters and subscribe to get push notification when someone submits an ad that matches those filters
- I save those filters in my database for that user
- For this example letís say my site has around 100k active subscriptions.

The first step is obviously to attack a place in a code where ad is being saved to the database. Iím having a problem with how to know if that specific ad matches those filters.

I would need to go through 100k subscriptions and their filters to know which filter matches the ad that has been posted. It doesnít sound too good for me, it could be 1M filters or more.

Can someone help me with that or at least point me to the right direction.

This is basic version.

Filters:
- country, county, city
- min price, max price
- condition (new,oldÖ)
- ads with/without picture

User A subscribed to set of filters:
- England, London
- Min price: 200 Ä
- X
- X

User B subscribed to set of filters:
- England
- Max Price: 500Ä
- New
- X

User C subscribed to set of filters:
- Germany
- Min price: 200 Ä
- X
- With pictures

User X submitted ad with following data:
- City: London
- Price: 300 Ä
- Condition: New

In this case User A and User B need to get push notification because ad matches their filters.
Sep 27 '20 #1
2 2276
How are you saving the filters to your database? Are you saving each filter to its own field e.g England to country field or you concatenate the filter e.g England, max price Ä200 before saving to database?
Sep 27 '20 #2
dada1
15
Each ad has columns like:
id | title | country_id | price

But when I save filters to the database (once users subscribe to them) I save it as json object {"price": 500, "country_id": 2}

This can be changed of course if needed
Sep 27 '20 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by jim_geissman | last post: by
8 posts views Thread by Brian L. Troutwine | last post: by
1 post views Thread by gcdp | last post: by
reply views Thread by kamranasdasdas | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.