Add sanity checks and improve performance when searching for posts
|Reported by:||azaozz||Owned by:|
The search part of the main query is quite basic. It needs a few sanity checks that will also improve performance in some cases:
- Search string length. Most browsers would send between 2000 and 8000 (2KB - 8KB) characters in a GET request, including the URL. Search string longer than 1500 - 1600 chars doesn't make sense (this is urlencoded length).
- Looking at web search engines data and behavior, most searches are 4 words or less, and searches of more than 7 words are very rare. We should treat searches with lets say 10 or more terms as "sentence", i.e. match only the whole search string instead of splitting it and matching word by word. This would improve both quality of results and speed.
- All search engines discard very common or very short words. We can't get that sophisticated but can discard terms that are less than 3 characters long from the word by word part of the search. Again, this would improve both quality of results and speed.