14
votes

Solr newbie here.

I have created a Solr index and write a whole bunch of docs into it. I can see from the Solr admin page that the docs exist and the schema is fine as well. But when I perform a search using a test keyword I do not get any results back.

  1. On entering * : *

    into the query (in Solr admin page) I get all the results.

  2. However, when I enter any other query (e.g. a term or phrase) I get no results. I have verified that the field being queried is Indexed and contains the values I am searching for.

So I am confused what I am doing wrong.

5
Title field is Indexed, String and Stored, same as Description (which is my default search field)Mikos
BTW, I am using the Lucid Imagination Solr/Tomcat which runs through the setup application.Mikos
Switch to text field type. See my updated answer.Mauricio Scheffer
aha! thanks so much! let me try that...Mikos

5 Answers

13
votes

Probably you don't have a <defaultSearchField> correctly set up. See this question.

Another possibility: your field is of type string instead of text. String fields, in contrast to text fields, are not analyzed, but stored and indexed verbatim.

2
votes

I had the same issue with a new setup of Solr 8. The accepted answer is not valid anymore, because the <defaultSearchField> configuration will be deprecated.

As I found no answer to why Solr does not return results from any fields despite being indexed, I consulted the query documentation. What I found is the DisMax query parser:

The DisMax query parser is designed to process simple phrases (without complex syntax) entered by users and to search for individual terms across several fields using different weighting (boosts) based on the significance of each field. Additional options enable users to influence the score based on rules specific to each use case (independent of user input).

In contrast, the default Lucene parser only speaks about searching one field. So I gave DisMax a try and it worked very well!

Query example:

http://localhost:8983/solr/techproducts/select?defType=dismax&q=video

You can also specify which fields to search exactly to prevent unwanted side effects. Multiple fields are separated by spaces which translate to + in URLs:

http://localhost:8983/solr/techproducts/select?defType=dismax&q=video&qf=features+text

Last but not least, give the fields a weight:

http://localhost:8983/solr/techproducts/select?defType=dismax&q=video&qf=features^20.0+text^0.3

If you are using pysolr like I do, you can add those parameters to your search request like this:

results = solr.search('search term', **{
    'defType': 'dismax',
    'qf': 'features text'
})
1
votes

In my case the problem was the format of the query. It seems that my setup, by default, was looking and an exact match to the entire value of the field. So, in order to get results if I was searching for the sit I had to query *sit*, i.e. use wildcards to get the expected result.

-1
votes

With solr 4, I had to solve this as per Mauricio's answer by defining type="text_en" to the field.

-1
votes

With solr 6, use text_general.