Search code examples
phpsymfonyelasticsearchlucenefoselasticabundle

Symfony search with tags


We're building an application that has multiple different entities that are pretty simple with name & description and some specific stuff.

Now we want to add tags, for the purpose of adding extra search keywords. (There will also be a tag cloud somewhere, but that's easy)

I've been reading up on different ways to do a proper search. Solutions like lucene, elastic, mysql fulltext match against and more.

Does anyone have any experience to share on the best solution for an application like this?

  1. Should I put the tags in the same table in a string/array field? Use a seperate table? I've also found DoctrineExtensions-Taggable which seems pretty decent and will make it easy to make a tagcloud too.
  2. For a proper search over name, description & tags, what's the best solution? lucene? elastic? myssql? So far I think the FOSElasticaBundle looks the most mature, but not sure how to add search on tags there? (see 1)

Thanks for the advice!


Solution

  • "What's the best..." is usually not a good way to ask here and you will either get very opinionated answers or none at all.

    So here is my opinionated answer:

    If you have a small set you can surely run with MySQL and MATCH AGAINST (you need to teach Doctrine how to use it!). It's the most straight forward thing to do because you already have Doctrine and just need to teach it a little bit of stuff. So yeah, Gedmo Taggable and a bit of your own Doctrine Extension and you have your Queries.

    If your Searchable Database will get larger you will want to switch to a proper search engine like Elastic or Solr or whatever else.

    What you will need there is usually called "Faceted Search" (or in ElasticSearch they are called "Aggregations" nowadays).

    More infos about Faceted Search you find on Wikipedia for example.

    Yes, a proper Search Engine is cooler and faster and flashy, but if you work on it on a schedule and for the first time, it might not be the best solution.