[MGNLEESOLR-65] FacetedSolrSearchProvider should not cache search queries since Solr index might have changed Created: 28/May/15  Updated: 15/Apr/16  Resolved: 29/Jul/15

Status: Closed
Project: Solr Search Provider
Component/s: None
Affects Version/s: 2.0
Fix Version/s: 3.0

Type: Bug Priority: Critical
Reporter: Edgar Vonk Assignee: Milan Divilek
Resolution: Fixed Votes: 0
Labels: backlog541
Remaining Estimate: 2d 6h 27.75m
Time Spent: 1h 32.25m
Original Estimate: 3d
Environment:

Solr 4, crawler


Issue Links:
causality
dependency
is depended upon by MGNLEESOLR-64 FacetedSolrSearchProvider#removeOutda... Closed
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:
Visible to:
Michaƫl van der Mark
Sprint: Sprint 3 (Kromeriz)
Story Points: 5

 Description   

I think since version 2.2 the FacetedSolrSearchProvider does some sort of (in memory) caching of the last performed search query. It does not perform a new search when the search query string is the same as the previous one.

This of course can never work since the Solr index might very well have changed in between the two queries! We now see this issue on our servers in the following scenario:

  1. Remove all documents from the index
  2. Perform a search on search string 'test'
  3. The search correctly returns no results
  4. (re)create the Solr index. In our case by starting the crawler from the content-indexer module
  5. Perform the same search again.
  6. The search still returns no results even though there are many hits in the new Solr index..

The solution is very simple: please remove this caching feature altogether. Unless I don't understand it I think this is a mistake. If any caching is done it should be done by the Solr server itself. That is what Solr is for.



 Comments   
Comment by Edgar Vonk [ 28/May/15 ]

Fixed the issue by implementing the following workaround in our custom version of the FacetedSolrSearchProvider in the search method:

  1. replace this code:
    if (!query.equals(this.query)) {
      invalidateSearchResults();
      resetFilters();
      this.query = query;
    }

    by:

    invalidateSearchResults();
    resetFilters();
    this.query = query;
  2. remove this if statement altogether:
    if (searchResultItems != null) {
      LOG.debug("Search is same as before, use search results from previous search." + model.getDefinition().getId());
    } { ..} 
Generated at Mon Feb 12 10:59:45 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.