1

First of all, I'm not very experienced in using Solr, so I hope this isn't a stupid question .. I am experiencing some unexpected behavior with a Solr query. Suppose the query is q="Foo:"Bar" . Now make it q="Foo:"Bar" AND() and we get more results back, which just seem random and certainly not meeting condition "Foo" = "Bar".

Am I missing something here? It doesn't seem logical that an extra condition would return more results instead of less.

Hanno
  • 1,017
  • 11
  • 18
  • Hi, can you please provide complete query you used? FYI. q=foo:abc AND foo1:def works very fine. – raghu777 Feb 25 '19 at 17:16
  • 1
    You might want to add "&debugQuery=true" to your query and look at what Solr reports under the "parsedquery" in the result to make sure your query is being interpreted correctly. See here for more info on this: https://github.com/hectorcorrea/solr-for-newbies/blob/master/tutorial.md – Hector Correa Feb 25 '19 at 19:19

1 Answers1

2

Your example queries are not valid Solr queries - if you want to query the field "Foo" for the value "Bar", do Foo:Bar. The AND clause is used between several terms to combine the result for all the terms, i.e. Foo:Bar AND Spam:Eggs.

Your example probably just got parsed to be either Foo:Bar or the value AND somewhere in the default search field.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84
  • It wasn't the actual query of course ;) Also the AND () was more complex in reality, also including OR, but your final remark was right! The query was returning results that contained AND or OR in the default search field, I would never have figured out that that was the case, thanks. – Hanno Feb 26 '19 at 06:43