skip to Main Content

I am writing a full stack application using Flutter-NodeJS-Cassandra. I want to add a search bar that user can search something inside the database, like a specific product for example. Also a suggestion list will be available while user is writing into the search bar( like what we see in many websites/applications or google map when it suggests for similar locations to what has been typed by user so far).

I don’t know what is the best way of doing that?

  1. Should I capture every changes user makes in the textField and make a query to the database for each change happen? (one query for each change).

  2. Should I read all the data from database first, then search what user tries to find in the front-end application? (only one query for all the available data).

2

Answers


  1. You could do either of those that you suggested, but it would be very expensive to look up incomplete words. Besides that, in Cassandra, you would need exact partition keys, which probably wouldn’t help you if the words were incomplete. For instance, if my table’s partition key is (color), and I type, blu and do a search, that doesn’t help me at all because nothing will come up in base Cassandra.

    What you probably need is a predictive text library, for example:

    https://pypi.org/project/pressagio/

    Along with something like Solr Search or Elastic to be able to index your table and search on keywords.

    Given the previous example, Solr and Elastic would allow you to use blu* and find everything with the letters blu in it.

    Login or Signup to reply.
  2. You may alternatively use DSE Search. See this example.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search