Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance search by upgrading city2tour #123

Closed
martinheppner opened this issue Jul 14, 2024 · 1 comment
Closed

Enhance search by upgrading city2tour #123

martinheppner opened this issue Jul 14, 2024 · 1 comment
Assignees

Comments

@martinheppner
Copy link
Contributor

SELECT t.id, c2t.provider, c2t.hashed_url, c2t.city_slug, c2t.reachable_from_country, c2t.min_connection_duration, u.min_connection_no_of_transfers, t.url, t.title, t.description, t.ascent, t.descent, t.difficulty, t.duration, t.distance, t.type, t.number_of_days, t.traverse, t.country, t.state, t.range_slug, t.range, t.quality_rating, t.search_column, t.text_lang, CASE WHEN t.text_lang='de' THEN 1 ELSE 0 END AS order_lang_de, CASE WHEN t.text_lang='en' THEN 1 ELSE 0 END AS order_lang_en, CASE WHEN t.text_lang='fr' THEN 1 ELSE 0 END AS order_lang_fr, CASE WHEN t.text_lang='sl' THEN 1 ELSE 0 END AS order_lang_sl, CASE WHEN t.text_lang='it' THEN 1 ELSE 0 END AS order_lang_it FROM city2tour AS c2t INNER JOIN tour AS t ON c2t.tour_id=t.id INNER JOIN (SELECT hashed_url, city_slug, MIN(connection_no_of_transfers) AS min_connection_no_of_transfers FROM fahrplan GROUP BY hashed_url, city_slug ) AS u ON c2t.hashed_url=u.hashed_url AND c2t.city_slug=u.city_slug WHERE c2t.reachable_from_country='SI' AND c2t.city_slug='ljubljana' AND t.search_column @@ websearch_to_tsquery('simple', 'triglav') ORDER BY order_lang_sl DESC, COALESCE(ts_rank(COALESCE(t.search_column, ''), COALESCE(websearch_to_tsquery('simple', 'triglav'), '')), 0) DESC, u.min_connection_no_of_transfers ASC, t.traverse DESC, c2t.min_connection_duration ASC, t.quality_rating DESC

@martinheppner martinheppner self-assigned this Jul 14, 2024
@martinheppner
Copy link
Contributor Author

SELECT 
t.id, 
t.provider, 
t.hashed_url, 
t.url, 
t.title, 
t.description, 
t.type, 
t.country, 
t.state, 
t.range_slug, 
t.range, 
t.search_column, 
t.text_lang, 
CASE WHEN t.text_lang='de' THEN 1 ELSE 0 END AS order_lang_de, 
CASE WHEN t.text_lang='en' THEN 1 ELSE 0 END AS order_lang_en, 
CASE WHEN t.text_lang='fr' THEN 1 ELSE 0 END AS order_lang_fr, 
CASE WHEN t.text_lang='sl' THEN 1 ELSE 0 END AS order_lang_sl, 
CASE WHEN t.text_lang='it' THEN 1 ELSE 0 END AS order_lang_it,
min(c2t.min_connection_duration) AS min_connection_duration, 
min(c2t.min_connection_no_of_transfers) AS min_connection_no_of_transfers, 
min(t.ascent) AS ascent, 
min(t.descent) AS descent, 
min(t.difficulty) AS difficulty, 
min(t.duration) AS duration, 
min(t.distance) AS distance, 
min(t.number_of_days) AS number_of_days, 
min(t.traverse) AS traverse, 
avg(t.quality_rating) AS quality_rating
FROM city2tour AS c2t 
INNER JOIN tour AS t 
ON c2t.tour_id=t.id 
WHERE c2t.reachable_from_country='SI' 
-- AND c2t.city_slug='ljubljana' 
-- AND t.search_column @@ websearch_to_tsquery('simple', 'triglav')
GROUP BY t.id, 
t.provider, 
t.hashed_url, 
t.url, 
t.title, 
t.description, 
t.type, 
t.country, 
t.state, 
t.range_slug, 
t.range, 
t.search_column, 
t.text_lang, 
CASE WHEN t.text_lang='de' THEN 1 ELSE 0 END, 
CASE WHEN t.text_lang='en' THEN 1 ELSE 0 END, 
CASE WHEN t.text_lang='fr' THEN 1 ELSE 0 END, 
CASE WHEN t.text_lang='sl' THEN 1 ELSE 0 END, 
CASE WHEN t.text_lang='it' THEN 1 ELSE 0 END 
ORDER BY order_lang_sl DESC,
-- COALESCE(ts_rank(COALESCE(t.search_column, ''), COALESCE(websearch_to_tsquery('simple', 'triglav'), '')), 0) DESC, 
min(c2t.min_connection_no_of_transfers) ASC, t.traverse DESC, ROUND(min(c2t.min_connection_duration) / 30, 0) ASC, t.quality_rating DESC 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

1 participant