[MGNLEESOLR-46] Search results model without queryStr parameter returns cached result Created: 17/Feb/15 Updated: 27/Apr/15 Resolved: 14/Apr/15 |
|
| Status: | Closed |
| Project: | Solr Search Provider |
| Component/s: | None |
| Affects Version/s: | 2.0 |
| Fix Version/s: | 2.2 |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Edgar Vonk | Assignee: | Milan Divilek |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Template: |
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
| Date of First Response: |
| Description |
|
Scenario:
You can see it in action on: Or e.g. |
| Comments |
| Comment by Edgar Vonk [ 16/Mar/15 ] |
|
This is probably our biggest issue with the Solr Module at the moment. The thing is also that since we use a Solr crawler to index our site, this crawler also indexes our 'empty' Solr search page (like https://www.magnolia-cms.com/search.html). And so our real Solr search results also include this Solr page itself.. I had a quick look at the FacetedSearchResultModel and I don't really follow the logic there. When no query string is provided an 'empty' search is done. I.e. a wildcard search I guess. Since the page is a normal Magnolia page without any request parameters in this case of course it gets cached by Magnolia and this search is never performed again. In all undesirable. What we would like to see is: no query string means no search is done at all. Just like Google etc does. No query string, no search. Simple. Of course we can implement this in our own custom search result model but I think it would be good to change this in the FacetedSearchResultModel if only so that all other users will avoid this issue. |
| Comment by Edgar Vonk [ 16/Mar/15 ] |
|
Oh, and to make the FacetedSearchResultModel class more extensible, is it possible to expose the two private methods to superclasses by changing their visibility to protected? That way people can extend the #execute method more easily. |
| Comment by Edgar Vonk [ 16/Mar/15 ] |
|
We implemented a workaround for now by extending the FacetedSearchResultModel class as follows: public class EaieFacetedSearchResultModel extends FacetedSearchResultModel { [..] /** * Only performs a search by calling {@link super#execute()} if a query string was provided. * * @return "ok" if a query string was provided; "noQueryString" otherwise */ @Override public String execute() { String status; if (getQueryStr() == null || getQueryStr().isEmpty()) { status = STATUS_NO_QUERY_STRING; } else { super.execute(); status = STATUS_OK; } return status; } } |
| Comment by Edgar Vonk [ 13/Apr/15 ] |
|
Nice. thanks @milan: could you share the solution maybe so we can efficiently remove our workaround in the future? |
| Comment by Jan Haderka [ 13/Apr/15 ] |
|
{{ if (getQueryStr() == null || StringUtils.isBlank(getQueryStr())) {}} BTW there should be test for this kind of error. |
| Comment by Milan Divilek [ 14/Apr/15 ] |
|
Hello Edgar, I agree that when no queryString then also search should not be triggered. So info.magnolia.search.solrsearchprovider.logic.model.FacetedSearchResultModel simply checks if queryString is blank or not. If queryString is blank then model invalidate cached search results in info.magnolia.search.solrsearchprovider.logic.providers.FacetedSolrSearchProvider and return "noQueryString". |
| Comment by Edgar Vonk [ 14/Apr/15 ] |
|
Thanks Milan! |