Posted on 10/09/2015 15:03:56
Hi Lars,
This is because that operator behaves a bit differently than a Contains operation on a string or a LIKE operator in SQL. This is due to how Lucene works with wildcard searches. The behavior is that it checks each term in the search input to see if there is at least one term in the index that starts with those terms. You can think of it like the search routine check each part of the search input against the result to see if there's a result part that begins with the input part.
Consider this sentence as a result in the index: My blue bike.
If I pass "bl bi" into a expression using the Contains operator, it will match anything that contains the parts "bl*" and "bi*", therefore my sentence from above is matched. If I passed in "lue ike", I would get no results, because there are no results containing the parts "lue*" and "ike*".
It is possible in Lucene to change that behavior, but it's strongly recommended not to do that as it comes with a high performance cost. This is the reason it works like this in new indexing.
This is also how Google handles search, by the way -- though they have extra heuristic features surrounding their search.
- Jeppe