[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: PNG File Screen Shot 2015-02-17 at 16.29.53.png    
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:

  1. Request the search results page (page template from Solr module) but do not specify the queryStr request parameter.
  2. You see to your surprise the search results of a previously cached query (probably the first query ever done).
  3. Instead you would want to see no results at all. You did not search for anything.

You can see it in action on:
https://www.magnolia-cms.com/search.html

Or e.g.
https://www.magnolia-cms.com/search.html?search=ja



 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())) {}}
Why? isBlank() would return true also for null.

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!

Generated at Mon Feb 12 10:59:34 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.