# When flying from Oslo to London, you don't want to go via Moscow

DevFeed: [When flying from Oslo to London, you don't want to go via Moscow](<https://devfeed.tech/articles/when-flying-from-oslo-to-london-you-don-t-want-to-go-via-moscow-31995.md>)

Original publisher: [Read original article](<https://tech.finn.no2015/06/15/removing-long-travels-in-the-flight-search/>)

Author: Per Jørgen Walstrøm

Published: 2015-06-15T12:47:32Z

Content type: article

Language: en

Sources: [Finn.no](<https://devfeed.tech/sources/finn-no.md>)

Topics: [Flight](<https://devfeed.tech/topics/flight.md>), [Query (disambiguation)](<https://devfeed.tech/topics/query.md>)

Tags: [query](<https://devfeed.tech/tags/query.md>), [results](<https://devfeed.tech/tags/results.md>), [search](<https://devfeed.tech/tags/search.md>), [travel](<https://devfeed.tech/tags/travel.md>)

## AI overview

The article explains how FINN Flight Search addresses implausibly long itineraries, such as routes from Oslo to London with distant layovers. It reviews a simple duration threshold, discusses using quartiles and the upper-fence rule to identify outliers, and notes that Solr requires a separate query to calculate quartiles.

## Source excerpt

If you want to travel from Oslo to London, you may end up getting results which include layovers in far-away places. Do you really want to spend a night at the airport in Moscow if you only want to go from Oslo to London? Probably not, but nonetheless, some of the results we receive at the FINN Flight Search are those kind of travels. Those travels may be really cheap, ending up at the top of our result list as we sort by price, but they are mostly garbage and we do not want our users to be confused by those outliers. We want them to go away! The old solution We have tried to fix this before. With limited success. A solution we used a couple of years back was something like this: x = 3 * Average of the three shortest flights We removed results with duration > x. This works fine on short travels, like a two-hour flight from Oslo to London. With the given formula, all trips longer than 6 hours to London will be removed. That's ok. However, it doesn't work too well on longer flights. If you want to go from Oslo to Bangkok, you would probably spend at least 11 hours in the air. In that case, it would be too conservative to just remove the flights that are 33 hours or more. A theoretical solution The correct way to remove the outliers is by finding the quartiles. When the quartiles are found, the upper fence is defined by Upper fence = Q1 + 1.5 * IQR Where IQR is the Interquartile Range; Q3 - Q1. We are using Solr at FINN, but the stats query in Solr does not give us the quartiles out of the box, so we would need to do a separate query to calculate the quartiles. Should be easy enough. What is too long? So what is a too long flight? That's not an easy question to answer. Racking our brains (and doing some guesswork), we came up with the following suggestions on what the upper fence on duration to different destinations should be. The durations are per leg: OSL - LON 300 mins = 5 hrs. Given the minimum flight time OSL - LON = 115 OSL - BKK (Bangkok) 1000 mins = 17 hrs. Mi