How to build complex search. EAV. FTS

Viewed 146

I'm building a complex search feature for a real estate listing site. To be able to search by a property category attributes I defined the model like this:

  • Each Property has a Category. Categories are nested.
  • Each Category holds a JSON specification for attributes it supports.
  • Each Property has a list of attributes (as JSON field)

Here are the entities (keys, relationships, methods are omitted):

class Property(db.Model):
    name = db.Column(db.String(255), nullable=False)
    description = db.Column(db.Text, nullable=False)
    address_line = db.Column(db.String(255), nullable=False)
    price = db.Column(MoneyType, nullable=False)    
    attributes = db.Column(JSONB)

class Category(db.Model, BaseNestedSets):
    name = db.Column(db.String(255), index=True, nullable=False)
    spec = db.Column(JSONB)
    override_spec = db.Column(db.BOOLEAN, default=True)
  1. So searching by categories-attributes (without FTS) would require a user to drill down the categories tree, pick a category, provide a search input based on available textboxes, dropdowns for supported attributes.

  2. We also have address, description, name which, I think, should be searched using FTS engine.

  3. I know I can build a search index when creating new Property record with all necessary data and then use a faceted search (this requires some explanation).

How can I combine aspects 1-2 or 2-3 with mind? Can you explain the routine?

0 Answers
Related