Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a website with a searchbar to query a mongo database?

I have a large mongoDB database set up and am trying to create a website where a user can use a searchbar to query the database remotely and have the results posted on the site (strictly read-only).

I have experience with databases for data analysis, but have never created a website for querying results.

I'm don't have any experience with web development and don't know what platforms (PHP? node.js?) to use.

Thanks in advance.

like image 372
SLee Avatar asked Sep 05 '25 03:09

SLee


1 Answers

There are the following steps to the problem:

  1. Create the front-end, which will consist of HTML, CSS, and Javascript. Beginners often find it easiest to work with jQuery and jQuery UI, because they are well-documented and contain plugins for almost all possible scenarios (they should not, however, be used to create large complex applications!). Bootstrap or Foundation can help you with the HTML / CSS.
  2. Create a (probably) JSON API, which the front-end can communicate with to submit searches and retrieve results. You could use PHP, Python, Ruby, or many other languages to do this. For a simple site like the one you're describing, it's more a matter of preference than anything else.
  3. Translate the search request from the front-end into the MongoDB query APIs, and return the results through the API. You will use a MongoDB client library compatible with whatever language you have chosen.

Depending on your needs, you may be able to eliminate (2) by using an existing REST API for MongoDB.

Note that if you just want to make MongoDB data accessible via searching / charting, then you may be able to avoid coding altogether by leveraging SlamData, an open source project I contribute to. SlamData lets you use Google-style search (or more advanced SQL) to query MongoDB and get the results back in tabular or chart form.

like image 165
John A. De Goes Avatar answered Sep 09 '25 03:09

John A. De Goes