Apply search filters in java

We need to implement a search filter (for Net-log like) for my social network site in relation to the user profile, filters for the profile include age range, gender and interests

we have approximately 1M profiles running on MySQL, MySQL does not seem to be the right option for implementing such filters, so we also look at Cassandra,

So, what is the best way to implement such a filter, the result should be very fast

eg. age = 18 - 24 and gender = man and percent = football

Age by date, gender and interests - varchar

Editions:
Let me rephrase the problem. How can I get a quick result of any type of search. It can be based on the profile name or any other profile in the 1M profile reports.

thanks

+4
source share
2 answers

This will serve your project to make a basic SQL change. Perhaps you should consider changing the Percentage column from the free input field (varchar) to a tag (for example, Many-to-many in an additional table).

You used the Football example and it had a like operator. If you changed it to a tag, then you will have the initial structural problem of choosing a placement:

 football Football American Football Australian-rules football 

But once you do, tags will help your select query faster.

Without this change, you will redirect your data management problem from the database (which is equipped to process it) to Java (which may not be).

+3
source

It may make sense to try to optimize your query (maybe at least some things you can do). It looks like you have a large database, and if you return a large set of results and filter the results using java, you may get performance problems due to all the data stored in the cache.

If so, one thing you could try is to search for caching results, outside the database, and read from it. It is something that Hibernate works very well , but you can implement your own version if necessary. If this interests you, Memcached is a good place to start.

I just noticed this for MySQL. I don’t know how effective this is, but they have a built-in full-text search function that can help speed up the process.

0
source

All Articles