I'm currently building an e-commerce website that's going to be backed by a SQLite3 database. I'm looking for a way to do an in-browser search, with the results being links to products that match the search query. I've got no idea where to start. Any suggestions?
Why? If you have enough products that you need search, use a database that will grow with you. SQLite is more for development and small/low-traffic applications. For example, Google Chrome uses it to store your history.
For very basic search, SQL-based finding is okay. You can do
SELECT * FROM foo WHERE bar LIKE "%query%" LIMIT 10;
…fairly easily, and relatively quickly (especially since you're using an index on that column, right?).
For more advanced or high-performance search with conditions, partial matches and searching across tables, you can use SOLR or another third-party search-specific application.
Related
I am trying to add to my website a search bar like the one on Facebook. I want my users to be able to search through my products, my other users ... But I also want the result to be displayed in real time without pressing a button. I am currently looking at several options (thinking-sphinx, ferret, ...) but I am not sure which one to use and that's why I would like to get advices from pros ;)
So my requirement are :
Result to be displayed in real-time in a box on the current page.
Css Customizable
Be able to search through severals table in my PostGreSQL DB.
I am currently using Heroku for production.
I want to choose the best one for my needs and that's why I am asking your opinion.
Thanks in advance !
Make sure to separate how you want data displayed (your first two requirements) from how you want it indexed (third) from how you want to deploy.
Let's start backwards. Heroku provides limited support for machine configuration; both options you mention require installation of a service that reads and writes files. Heroku has such an option in two ways: 1) PostgreSQL has a built-in full-text search capability, and 2) Heroku has made Flying Sphinx an option, as well as these other options documented on the Heroku site. The first two options may provide the easiest linkage to your database, but I haven't tried other options, so it's possible they do too. So now you have a search index, deployed.
Real-time "incremental" search is purely a matter of presentation ... and maybe performance. Start typing and you start getting results is nothing more than sending requests via AJAX to the search server, typically after a short delay in typing (maybe 50ms), and handling the display of results. There are a couple of ways to make that simple written up here in this SO answer.
I ended up keeping the PostgreSQL engine for now but used select2 as the jquery for the presentation and was able to get a facebook like search box :
Select2 with Rails and JSON
Thanks for you help !
I am working on a rails application that uses sunspot solr for search. I have been asked to log (or capture in some way) each search that happens on the site; the query, the user that did the search, the result count that resulted from their search...etc, so that the company can report on what people are searching on (demand), and other things.
Before I go and make a table, that will receive an ever-growing number of rows of search data, I'm wondering if anyone has done this in a better way? Can I use analytics (google?) in some way for this? Is there some kind of service I can send this information too, such that we could easily pull reports, or create reports from?
In short, is there some better/smarter way than creating my own table and storing this all in our own DB?
I had never done this, but here are some thoughts.
If you just need to store that data I think you should do it yourself.
If you need to also provide a way to analyse the data yes, see if there is anything already done (I'm not sure but it seems google analytics only support internal search using their search bar).
If your client already have some BI tool they just need a way to access the data, and it would be easier to have it in a owned DB wich you can easily be query instead of using a provider api.
I've tried thinking sphinx after being pointed in that direction and simple filtering seems impossible. I've googled and asked questions for 2 days now and it seems it can't be done which is shocking because it's something commonly done when searching on websites.
All I would like to do add filtering options to my search form such as filtering by one or a combination of:
When user hits browse page all the sites users are returned but showing 20 results per page
Filtering options
in: location
who are: sexual preference
between the ages: age range
and located in: country
My search page works fine because all I require is 1 textfield a user uses for finding users by email, username or full name. My browse page is a different story because I'm using 1 form with multiple text fields and one or two select fields.
Example
Is there a gem that does this easily and performs well at the same time?
or would doing this manually via find methods be the only way?
Kind regards
Apart from using Sphinx and Thinking Sphinx, you can think of those gems: meta_where and meta_search
However after reading your description I think Sphinx is the best choice here indeed.
You wrote that it seems impossible to apply simple filtering using Thinking Sphinx. Let me explain a bit of Thinking Sphinx within the post you mentioned under the link: Example
You can go for Elasticsearch. Ruby has the 'Tire' gem, which is a client for ElasticSearch http://www.elasticsearch.org/
I have a mediawiki installation that I've customized with some of my own extensions. Here is the basic platform, pretty standard LAMP install.
Ubuntu Server
Apache 2
Mediawiki 1.15
PHP 5.2.6
MySQL 5.0.67
For the actual MW search I use Lucene (EzMwLucene). I also have custom extension that displays tabular data from a separate database within a MW page. Lucene doesn't index this info (which, in my case is actually good because it would clutter your expected search results). For this installation I didn't do anything to Lucene other than install it and wouldn't know how to customize it for my needs and it may be "too powerful".
At any rate, I need to create a search for the data in my other database. I have a master table that is updated daily based on data stored in other (normalized) tables. At the moment it is one of these searches that basically creates a SQL query based on the criteria you enter. This is a lot of work, though. I would like it to be more of a "type and submit" type search.
I don't think I need a comprehensive "cut & paste" type answer, but if anybody has something that I can google I would be very appreciative. I don't need to recreate the wheel, which is what I would be doing if I followed what I see in google.
If you would like to see my master database, let me know, I would want to sanitize it to make me more anonymous (whatever that means). Also, if you're familiar with MW and would like to see any of my extension code, again, let me know.
TL;DR: need to make a custom search feature with LAMP (displayed in Mediawiki). Any guidance appreciated.
Thanks SO!
Why do you need to add custom search? This will relate to the best answer.
For simplicity, you could use the Google Search Engine - http://www.mediawiki.org/wiki/Extension:Google_Custom_Search_Engine
Otherwise it sounds like you need to write a full-text query for the database.
I'm looking into implementing full text search on our Firebird database. Our requirements are:
Every field in several tables should be indexed. When a result is found we should be able to find out the originating table.
The index can be stored in the database or in the file system.
The results of the search (BigInt primary keys) must be used to join with the original records in the database to display the records in a table.
Can anybody recommend a decent way to achieve what we need? I've looked at somehow integrating DotLucence into Delphi, but can't really find very much information on how to go about it.
Here are a few resources for you to consider:
Sphinx very powerful and popular free open source full-text search engine.
Textolution Fulltext search for Interbase and Firebird.
IBObjects Full Text Search ("Fuzzy Search") module, a fully working module that can be used to set up your search indexes or as a model for your own custom implementation.
Rubicon is a Delphi add-on that lets you put full text search capabilities into your applications.
Fulltext Search for Firebird SQL By Dan Letecky on CodeProject using DotLucene full-text search engine.
Mutis is a Delphi port of the Lucene Search Engine. Provide a flexible API for index, catalog and search text-based information with great performance. Excelent for implement custom search engines, researching, text retrieval, data mining and more.
There is a fork of Firebird code made by a company called Red Soft. It's licensed under the same license as Firebird, so you can take a look at their version which can support full-text searches using Lucene engine via JavaVM interfaces.
You can also read a paper titled "Full text search in Firebird without a full text search engine" by Bjoern Reimer and Dirk Baumeister, presented at 4th Firebird Conference.
I think you will have a problem with requirement 2: The index can be stored in the database or in the file system. Most indexing services create their own index file which stores data in a highly optimized way. If you really want it, maybe it is possible to load and save an index to a single blob field but I don't really see a reason for this.