Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add option to completely remove query-string from SearchRequest #4135

Open
rr-it opened this issue Aug 19, 2024 · 0 comments · May be fixed by #4136
Open

[FEATURE] Add option to completely remove query-string from SearchRequest #4135

rr-it opened this issue Aug 19, 2024 · 0 comments · May be fixed by #4136

Comments

@rr-it
Copy link
Contributor

rr-it commented Aug 19, 2024

Is your feature request related to a problem? Please describe.
Removing the query-string from a SearchRequest might be used to keep e.g. the category selections while not limiting the result by a search query string anymore.

In solr v11.2 it was possible to completely remove the query-string from a SearchRequest by setting it to null.

E.g. using a custom ViewHelper:

class RemoveQueryViewHelper extends AbstractUriViewHelper
{

    /**
     * @param array $arguments
     * @param \Closure $renderChildrenClosure
     * @param RenderingContextInterface $renderingContext
     * @return string
     */
    public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
    {
        $newRequest = static::getUsedSearchRequestFromRenderingContext($renderingContext)
            ->getCopyForSubRequest()
            ->setRawQueryString(null);
        $uri = self::getSearchUriBuilder($renderingContext)->getCurrentSearchUri($newRequest);
        return $uri;
    }
}

Introduced in solr v11.5 by 61076e3 the method SearchRequest::setRawQueryString(string $rawQueryString = '') enforces a string. Thereby it is no longer possible to set the query-string to null.

/**
* Method to overwrite the query string.
*/
public function setRawQueryString(string $rawQueryString = ''): SearchRequest

Describe the solution you'd like
Introduce a new method that removes the query-string from SearchRequest.

Describe alternatives you've considered
Alternative A:
Allow null as argument for the method:

    public function setRawQueryString(string|null $rawQueryString = ''): SearchRequest

Alternative B:
Set query string to empty string …->setRawQueryString(''):

But this will result in an unnecessary empty query-string in the url:
https://example.com/search/?tx_solr[filter][0]=altType%3ASomeCategory&tx_solr[q]=

Additional context
Completely removing the SearchRequest is afaik only usefull with allowEmptyQuery set in TS-config:

plugin.tx_solr {
  search {
    query {
      allowEmptyQuery = 1
    }
}

Target versions

  • 12.0
  • 11.5 (TBD)
rr-it added a commit to rr-it/ext-solr that referenced this issue Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant