0
votes

I am trying to understand why there is a difference in the following behaviors when searching using 'q' and 'df'. In my understanding, if 'q' is not specified, it will default to 'df'.

Example Aim of search is to look for 'Workout plans' in 'title' field of documents.

Search method #1 http://localhost:8983/solr/workoutstuff/select?q=title:Workout%20Plans&wt=json

Search method #2 http://localhost:8983/solr/workoutstuff/select?df=title&q=Workout%20Plans&wt=json

Results

There are results in Search Method #1 but no results in Search Method #2.

I would like to understand why. Thanks!

1

1 Answers

1
votes

If you don't specify a df, there will still probably be a default search field, probably the field text.(Depending on your configuration).

So for search method 1: The term Workout is searched for in the title field the word Plans is searched against the default field (probably text) because there are no quotes around the title expression. e.g. title:"Workout Plans"

Search method 2: Searches for Workout OR Plans in the default field, title. Again because there are no quotes.(Assuming the default operator is OR)

So your two search methods should return the same results if you put quotes around the search value.