2

I want a library that I can use with my site, in which I can input the title and description of all the items I have, and then input search terms in natural english and get relevant results. I am very willing to look into paid or even SaaS solutions, as well as open source software.


To avoid an X/Y problem, here is my problem:

I have this database of items that are being sold on an eCommerce site. People want to find items, and there is a search bar on the top. Before I got here, it simply took every keyword and did a query similar to

SELECT name,description,price,etc... 
FROM products 
WHERE name LIKE '%keyword1%' 
OR name LIKE '%keyword2%' 
OR description LIKE '%keyword1%' 
OR description LIKE '%keyword2%'

I then changed it to use MySQL's FULLTEXT index on both the name and description, and then implemented a homebrew solution to parse strings like "4 feet" in both the query and the title and match them as measurements instead of as bare text. Even now, many products do not appear when they should or are too far down the list. After all this, I realized certainly somebody has done this before and I should use their code instead of trying to do it myself, since I have sunk far too much time into this already.

  • 1
    FYI, 15,000 product items is not a "large" amount for nearly any database. – Basil Bourque Jul 23 '15 at 7:00
  • @BasilBourque fair enough, I've edited accordingly. – Shelvacu Jul 23 '15 at 22:33
2

A look at Apache Solr or ElasticSearch might be useful.

You can install them yourself or you can use some SaaS provider offering them.

0

MariaDB/MySQL already have (excellent) fulltext search. I recommend you first try use that one instead of some 3rd party library.

  • As I mentioned in my question, I have already tried using the fulltext search index. It works alright, but is not full-featured enough to fit my needs and I ended up having to add on to it, which quickly got very messy. In particular, it can't search for part numbers with dashes and doesn't let me prioritize some keywords over others. – Shelvacu Jul 23 '15 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.