Solr Index appears to be valid - but returns no results
Asked Answered
K

5

15

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.

Kinematograph answered 16/8, 2010 at 13:20 Comment(4)
Title field is Indexed, String and Stored, same as Description (which is my default search field)Kinematograph
BTW, I am using the Lucid Imagination Solr/Tomcat which runs through the setup application.Kinematograph
Switch to text field type. See my updated answer.Pulpiteer
aha! thanks so much! let me try that...Kinematograph
P
13

You probably don't have <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.

Pulpiteer answered 16/8, 2010 at 14:7 Comment(4)
Thanks Mauricio - I do have a default field setup. I also have tried field-specific queries e.g. Title:Patterns. But 0 results is perplexing.Kinematograph
That was it! Converting to text field typed did the trick. Silly me, well you learn something new every day. Thanks Mauricio.Kinematograph
I had the same issue, field type of text instead of string fixed it. Thanks!Photogravure
Are there any other possibilities? I did both of them, but still unable to get the result!Negrete
R
3

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'
})
Raychel answered 29/5, 2020 at 7:29 Comment(0)
T
1

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.

Tinct answered 9/2, 2021 at 14:1 Comment(0)
D
-1

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

Donee answered 25/6, 2013 at 8:48 Comment(0)
M
-1

With solr 6, use text_general.

Microchemistry answered 18/4, 2016 at 14:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.