简体   繁体   中英

No results from solr search q = *:*

Using solr 4.6.0 the following query returns no results:

solr/select/?q=*:*

But removing the q parameter returns all results, eg:

solr/select/

The request handler configuration contains the invarient:

<str name="q.alt">*:*</str>

Since q.alt is supposed to define the query when q is not provided, shouldn't the two queries be identical and return results? What are some possible reasons why the first form fails to return documents?

Additional Background

I'm using django-haystack 2.1.0 to actually connect to solr, the above queries are just the 'simplest failing case' in instances where empty queries are supplied. I've overloaded the haystack SearchForm to prevent empty queries returning empty result sets, and this worked with a much older version of solr and haystack 1.4.

Haystack "helpfully" populates q with *:* if no value is provided. Unfortunately, that's breaking the query as above. I could monkey-patch haystack, but I'd rather fix the problem in solr.

Note that queries with a populated (non-empty) q parameters work, eg

solr/select/?q=test

This will return results as expected.

Found the solution.

The search handler used DisMaxQParserPlugin (defType dismax ):

The DisMaxQParserPlugin is designed to process simple user entered phrases (without heavy syntax)...

The *:* form of q was invalid for the DisMax parser, but the q.alt provides a fallback that is "..parsed by default using standard query parsing syntax.." .

Changing the search handler plugin to ExtendedDisMax (defType edismax ) fixes the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM