Enhancing Property Search: Geocoding, Reactive Facets, and Large Datasets

Our ongoing work on the Inmotech-Backend project, a core component of Ryuu-no-Mi's property platform, recently focused on significantly improving its property search capabilities. With a catalog exceeding 30,000 properties, the challenge was to offer highly accurate geographical filtering and a responsive user experience through dynamic search facets.

The Challenge

Previously, our search functionality faced several limitations:

  • Limited Geographical Precision: Searching by distrito (district) or barrio (neighborhood) lacked the precision and flexibility required for a modern property platform.
  • Scalability with Large Datasets: Managing and efficiently querying over 30,000 property listings required optimized data access patterns to maintain performance.
  • Static Filtering Experience: Users needed a more interactive search, where filter options (facets) would dynamically update based on current search criteria, without slow page reloads.

The Solution

We tackled these challenges by integrating a robust geocoding solution, optimizing data handling for large volumes, and implementing reactive facets. Key aspects of the solution included:

  1. Nominatim Geocoding Integration: We integrated Nominatim, an open-source geocoding service, to accurately translate distrito and barrio names into precise geographical coordinates. This allows for more granular location-based searches.
  2. Optimized Property Data Access: To efficiently handle 30,000+ properties, we leveraged Spring Data's powerful repository pattern, ensuring that queries for geocoded locations and other criteria are highly performant.
  3. Reactive Facets and tipo IN Filtering: We introduced reactive facets, allowing filter options to update dynamically as users refine their search. This was combined with a flexible tipo IN filter, enabling users to select multiple property types simultaneously. This provides an intuitive and fast filtering experience.

Here's an illustrative Java example of how a PropertyRepository might support such filtering and geocoding queries using Spring Data:

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface PropertyRepository extends JpaRepository<Property, Long> {

    // Example of finding properties by district within a bounding box (after geocoding)
    @Query("SELECT p FROM Property p WHERE p.district = :district AND p.latitude BETWEEN :minLat AND :maxLat AND p.longitude BETWEEN :minLon AND :maxLon")
    Page<Property> findByDistrictAndLocation(
            @Param("district") String district,
            @Param("minLat") double minLat,
            @Param("maxLat") double maxLat,
            @Param("minLon") double minLon,
            @Param("maxLon") double maxLon,
            Pageable pageable);

    // Example of a 'tipo IN' filter to find properties by multiple types
    List<Property> findByTypeIn(List<String> types);

    // Method to calculate reactive facets (e.g., count properties by type for current filters)
    @Query("SELECT p.type, COUNT(p) FROM Property p WHERE p.district = :district GROUP BY p.type")
    List<Object[]> countPropertiesByTypeForDistrict(@Param("district") String district);
}

Key Decisions

  1. Nominatim for Geocoding: Chosen for its open-source nature, flexibility, and ability to handle granular location data, integrating seamlessly with our property data.
  2. Spring Data Repository Pattern: This was crucial for managing efficient data access for 30,000+ records, allowing us to define complex queries with minimal boilerplate.
  3. Reactive Facet Implementation: Prioritizing user experience, reactive facets were implemented to provide immediate feedback and filter updates, enhancing usability for complex searches.

Results

These enhancements have transformed the property search experience. Users now benefit from highly accurate geographical filtering, rapid result retrieval even with a large dataset, and an intuitive, dynamic filtering interface. This has significantly improved engagement and satisfaction on the platform.

Lessons Learned

Working with large geographical datasets and implementing reactive search features reinforced the importance of balancing data accuracy with query performance. Optimizing database indexes and choosing the right geocoding service are paramount when dealing with real-world location data at scale.


Generated with Gitvlg.com

Enhancing Property Search: Geocoding, Reactive Facets, and Large Datasets
JAIME ANDRÉS MONSERRATE VILLA

JAIME ANDRÉS MONSERRATE VILLA

Author

Share: