sismics / docs

Lightweight document management system packed with all the features you can expect from big expensive solutions
https://teedy.io
GNU General Public License v2.0
1.93k stars 486 forks source link

Search suggestion is enabled even without full search terms #723

Open archiloque opened 1 year ago

archiloque commented 1 year ago

In com.sismics.docs.core.util.indexing.LuceneIndexingHandler#findByCriteria I found this code:

        if (!Strings.isNullOrEmpty(criteria.getSimpleSearch()) || !Strings.isNullOrEmpty(criteria.getFullSearch())) {
            // …
            suggestSearchTerms(criteria.getFullSearch(), suggestionList);
        }

It means that if criteria.getSimpleSearch() is filled and criteria.getFullSearch() is null, suggestSearchTerms is called with a null parameter. It feels wrong => in this case should the suggestion search be skipped ?

jendib commented 12 months ago

You are right, suggestSearchTerms should only be called with a non null "search" parameter, otherwise it will throw NPE inside. Could you do a PR please?

archiloque commented 12 months ago

Thanks, I'll do a PR after https://github.com/sismics/docs/pull/722 is merged to avoid any conflict risk