The Property Search API provides advanced search functionality for properties with support for natural language queries, voice search integration, and intelligent filtering. The system includes text normalization for Roman Urdu and Urdu languages.
1# Search for properties in Lahore
2curl "http://localhost:8000/api/property/search_properties/?q=lahore"
3
4# Voice search example
5curl "http://localhost:8000/api/property/search_properties/?q=3%20bedroom%20house%20in%20lahore"
1# English
2GET /search_properties/?q=house in lahore
3
4# Roman Urdu
5GET /search_properties/?q=teen bedroom ka ghar lahore mein
6
7# Urdu Script
8GET /search_properties/?q=تین بیڈ روم کا گھر لاہور میں
1# Natural language
2GET /search_properties/?q=under 50000
3GET /search_properties/?q=above 100000
4GET /search_properties/?q=between 50000 and 100000
5
6# Explicit parameters
7GET /search_properties/?min_price=50000&max_price=100000
1# Minimum 3 bedrooms
2GET /search_properties/?q=3 bedrooms
3
4# Exactly 5 bedrooms
5GET /search_properties/?q=5 bedrooms&bed_match_type=exact
6
7# Combined filters
8GET /search_properties/?q=3 bedroom house&min_price=50000
1# By city
2GET /search_properties/?city=Lahore
3
4# By society
5GET /search_properties/?society=Defence
6
7# Combined
8GET /search_properties/?city=Lahore&society=Faisal%20Town
1# Complete example
2GET /search_properties/?q=3 bedroom house in lahore&min_price=50000&max_price=100000
3
4# Roman Urdu + price
5GET /search_properties/?q=teen bedroom ka ghar&min_price=50000
6
7# Location + bedrooms
8GET /search_properties/?city=Lahore&society=DHA&q=5 bedrooms
1{
2 "count": 4,
3 "limit": 20,
4 "search_criteria": [
5 "searching for: 3 bedroom house in lahore",
6 "keywords: bedroom, house, lahore",
7 "beds: 3+"
8 ],
9 "results": [
10 {
11 "id": 1,
12 "title": "Modern House",
13 "price": 75000,
14 "address": "Faisal Town",
15 "city": "Lahore",
16 "beds": 3,
17 "baths": 2,
18 "area": 5,
19 "area_unit": "Marla",
20 "status": "Approved"
21 }
22 ],
23 "summary": {
24 "total_found": 4,
25 "showing": 4,
26 "from": 1,
27 "to": 4
28 }
29}
1{
2 "count": 0,
3 "limit": 20,
4 "search_criteria": ["searching for: unknown place"],
5 "results": [],
6 "suggestion": "No properties found. Try: using fewer words, checking spelling, adjusting price range, or removing filters."
7}
1{
2 "error": "An unexpected error occurred while searching properties.",
3 "detail": "Error details in debug mode"
4}
1const recognition = new webkitSpeechRecognition();
2recognition.lang = 'ur-PK'; // Urdu language
3recognition.onresult = (event) => {
4 const query = event.results[0][0].transcript;
5 fetch(`/search_properties/?q=${encodeURIComponent(query)}`)
6 .then(response => response.json())
7 .then(data => displayResults(data));
8};
9recognition.start();
1# English
2"3 bedroom house in lahore"
3"properties under 50000"
4"plot for sale in defence"
5
6# Roman Urdu
7"teen bedroom ka ghar lahore mein"
8"under 50 hazar ke properties"
9"defence mein plot"
10
11# Mixed
12"3 bedroom ka ghar lahore mein"
13"property 50 lakh se kam"
1# Basic search
2curl "http://localhost:8000/api/property/search_properties/?q=lahore"
3
4# With pagination
5curl "http://localhost:8000/api/property/search_properties/?q=house&limit=10&offset=20"
6
7# All filters
8curl "http://localhost:8000/api/property/search_properties/?q=3%20bedroom&city=Lahore&min_price=50000&max_price=100000&bed_match_type=min&limit=20"
1import requests
2
3def search_properties(query, city=None, min_price=None, max_price=None):
4 url = "http://localhost:8000/api/property/search_properties/"
5 params = {
6 "q": query,
7 "city": city,
8 "min_price": min_price,
9 "max_price": max_price,
10 "limit": 20
11 }
12 response = requests.get(url, params=params)
13 return response.json()
14
15# Example usage
16results = search_properties("3 bedroom house in lahore", min_price=50000)
17print(f"Found {results['count']} properties")
-
Use specific terms
1# Good
2?q=3 bedroom house in lahore defence
3
4# Less specific
5?q=house
-
Combine filters
1# Good
2?q=house&city=Lahore&min_price=50000
3
4# Can be improved
5?q=house in lahore under 50000
-
Use voice search for natural language
- The API is optimized for speech-to-text input
- Normalization handles common voice recognition errors
1# Enable debug for detailed errors
2GET /search_properties/?q=test&debug=true
1# Most common searches
2/search_properties/?q=lahore
3/search_properties/?q=3 bedroom house
4/search_properties/?q=under 50000
5/search_properties/?q=plot in defence
6/search_properties/?q=teen bedroom ka ghar
7
8# With filters
9/search_properties/?city=Lahore&society=DHA
10/search_properties/?min_price=50000&max_price=100000
11/search_properties/?q=3 beds&bed_match_type=min
12
13# Pagination
14/search_properties/?q=house&limit=20&offset=0