Fuzzy Query not working on 3.3
Referenced from: https://my.dotcms.com/tickets/detail.dot?id=4c35c6e9-f656-44a0-8b21-dc424ba5dc0b
Fuzzy queries using "~" worked on dotCMS 2.5.7 with Lucene 3.6.1 but not on dotCMS 3.3. Possible problem on the repackaged version for 3.3 upgrading from Lucene 3.6.1 to 4.10.2. No error logs present.
I can confirm this is also an issue in 3.5:
I tried:
Working with regular query: +contentType:Blog +Blog.body:*pass* -> Returns 4 results
NOT working with Fuzzy search: +contentType:Blog +Blog.body:pass~ -> NO results
And according to: http://dotcms.com/docs/latest/content-search-syntax the code above using ~ should give us results:
Fuzzy Search dotCMS search queries support fuzzy searches based on the Levenshtein Distance. To do a fuzzy search use the tilde, "~", symbol at the end of a Single word Term. An additional (optional) parameter can specify the required similarity. The value is between 0 and 1, with a value closer to 1 only terms with a higher similarity will be matched. The default is 0.5 if no parameter is passed. The first example below (without the parameter), returns blogs with "passes, passing, compassion, passenger, impasse, passed" etc. The second example, however returns only the blogs where "pass" specifically appears in the body.
+contentType:Blog +Blog.body:pass~ +contentType:Blog +Blog.body:pass~0.8 (optional)
This is a an issue with the findAndReplaceQueryDates() method in the ESContentFactoryImpl. It translates the fuzzy query to:
+contenttype:blog +blog.body:pass\~
if you prevent that from happening, then the query works successfully.
You can replace these queries with the more powerful ES query language
{
"query" : {
"fuzzy" : { "blog.body" : "pass" }
},
"size": 10,
"from": 0
}
Jose, while we are in this method, can we confirm that the examples on our hint text work as well? They are pretty much the qa acceptance criteria.

Hi @wezell,
I tested with the following examples after applying my fix, and the results are correct:
| Lucene Query | Results | Status |
|---|---|---|
| +contentType:News +News.sysPublishDate:[01/25/2016 TO 01/28/2016] | 5 | Correct |
| +contentType:News +News.sysPublishDate:[01/25/2016 10:00:00PM TO 01/28/2016 10:00:00PM] | 3 | Correct |
| +contentType:News +News.sysPublishDate:20160125* | 2 | Correct |
| +contentType:News +News.sysPublishDate:2016012514* | 1 | Correct |
| +contentType:News +News.sysPublishDate:20160127230000 | 1 | Correct |
@jcastro-dotcms awesome! @john-thomas-dotcms lets doc.
PR: https://github.com/dotCMS/core/pull/8964
Incorrect code was added to escape the tilde (~) character. Escaping is necessary when filtering data from the Content Search portlet, which is already being done in this line: https://github.com/dotCMS/core/blob/master-3.5/src/com/dotmarketing/portlets/contentlet/ajax/ContentletAjax.java#L516
Users that run Lucene queries from the Query Tool portlet must know that the tilde needs to be escaped when looking for content that has such a character, as explained in our doc: http://dotcms.com/docs/latest/content-search-syntax , in the Escape Special Characters section.
master-3.6 PR: https://github.com/dotCMS/core/pull/9006
Fixed, tested on master-3.6 // H2 // FF
Is there anything new that needs to be doc'ed here? We have doc on the fuzzy search already here: http://auth.dotcms.com/docs/latest/content-search-syntax#FuzzySearch, and we document that characters need to be escaped here: http://auth.dotcms.com/docs/latest/content-search-syntax#EscapingCharacters
I'm not seeing anything else that needs to be doc'ed - please let me know if I'm missing something.