solrlucenesolrcloudsolr-schemasolr-search

Solr search results changes when query terms are jumbled up


I have indexed a file with fields -

  1. Content (type :text_general, uninvertible :false, indexed :true, stored :true)
  2. Category (type :text_general, uninvertible :false, indexed :true, stored :true)
  3. Title (type :text_general, uninvertible :false, indexed :true, stored :true)

with a catch-all copyfield-

source: *,
dest :_text_

Now when I search Content field, for query - Apple trade , I get 6057 docs;

But when I search - trade Apple , I get 5878 docs.

However when the same search is performed on the catch-all field , I get same result for both the queries (6057 docs).

I am not understanding the mistake here, as I would wish solr to give same result for both queries when searched on Content field.

I am using-

Two queries on 'Content' Field :

  1. Apple trade

http://localhost:8983/solr/core_name/select?q=Content%3A%20Apple%20trade

  1. trade Apple

http://localhost:8983/solr/core_name/select?q=Content%3A%20trade%20Apple


Solution

  • From what you just added to your question and assuming the Lucene query parser ignores the space after your :, the query is Content:trade <default search field>:Apple - you're not searching for both the first and second term in the Content field.

    When you swap their places, you're searching for Content:Apple <default search field>:trade.

    The default search field is _text_ in the default configuration. Since the queries are different, you can assume that there is different content in the field (for example by not reindexing properly and cleaning out the index after adding the copyField instruction).

    If you want to use free text search that easily maps to user input, use the edismax query parser instead (defType=edismax), supply the query in q=apple trade, and supply the field names in qf=Content.