Changes between Version 3 and Version 4 of AdvancedTopics


Ignore:
Timestamp:
06/11/26 10:34:44 (10 days ago)
Author:
231035
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AdvancedTopics

    v3 v4  
    2020}}}
    2121
    22 This column stores the semantic meaning of each property.We created a database view:{{{vw_property_embedding_text}}}
    23 This view prepares one text description for every property.This text is then converted into an embedding.
     22This column stores the semantic meaning of each property. Additionaly we created a new table for this phase.
     23{{{
     24CREATE TABLE user_recommendation_profiles (
     25    user_id BIGINT PRIMARY KEY
     26        REFERENCES users(user_id)
     27        ON DELETE CASCADE
     28        ON UPDATE CASCADE,
     29
     30    preference_embedding vector(384),
     31    updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
     32);
     33}}}
     34We created a database view:{{{vw_property_embedding_text}}}
     35This view prepares one text description for every property. This text is then converted into an embedding.
     36The view:
     37{{{
     38
     39CREATE OR REPLACE VIEW vw_property_embedding_text AS
     40SELECT
     41    p.property_id,
     42
     43    CONCAT(
     44        'Title: ', p.title, '. ',
     45        'Description: ', COALESCE(p.description, ''), '. ',
     46        'Listing type: ', lt.type_name, '. ',
     47        'City: ', a.city, '. ',
     48        'Country: ', c.country_name, '. ',
     49        'Base price: ', p.base_price, '. ',
     50        'Max guests: ', p.max_guests, '. ',
     51        'Property amenities: ', COALESCE(string_agg(DISTINCT pa_am.amenity_name, ', '), ''), '. ',
     52        'Room types: ', COALESCE(string_agg(DISTINCT rt.type_name, ', '), ''), '. ',
     53        'Room amenities: ', COALESCE(string_agg(DISTINCT ra_am.amenity_name, ', '), ''), '. ',
     54        'Average rating: ', COALESCE(ROUND(AVG(rv.rating)::numeric, 2), 0), '.'
     55    ) AS embedding_text
     56
     57FROM properties p
     58JOIN listing_types lt
     59    ON lt.listing_type_id = p.listing_type_id
     60JOIN addresses a
     61    ON a.address_id = p.address_id
     62JOIN countries c
     63    ON c.country_id = a.country_id
     64
     65LEFT JOIN property_amenities pa
     66    ON pa.property_id = p.property_id
     67LEFT JOIN amenities pa_am
     68    ON pa_am.amenity_id = pa.amenity_id
     69LEFT JOIN rooms r
     70    ON r.property_id = p.property_id
     71LEFT JOIN room_types rt
     72    ON rt.room_type_id = r.room_type_id
     73LEFT JOIN room_amenities ra
     74    ON ra.room_id = r.room_id
     75LEFT JOIN amenities ra_am
     76    ON ra_am.amenity_id = ra.amenity_id
     77
     78LEFT JOIN reviews rv
     79    ON rv.property_id = p.property_id
     80
     81GROUP BY
     82    p.property_id,
     83    p.title,
     84    p.description,
     85    p.base_price,
     86    p.max_guests,
     87    lt.type_name,
     88    a.city,
     89    c.country_name;
     90
     91}}}
    2492[[br]]
    2593[[br]]