axel wolf
axel wolf

Reputation: 1478

solr: use filter if field contains value

Trying to find solution to build query so I can filter certain docs like so:

if category = xyz 
   -created:[* TO NOW-7DAY/DAY]
else 
   no filtering

Is that generally possible or will I need to do this after receiving the results? And if possible, of course, how?

Upvotes: 0

Views: 895

Answers (2)

Alexandre Rafalovitch
Alexandre Rafalovitch

Reputation: 9789

You are looking for Switch parser from recent Solr. I also published an example that's used in multi-field advanced search. Notice that you can switch on specific value, presence of (any) value and missing value.

Upvotes: 1

MatsLindh
MatsLindh

Reputation: 52792

You can query for either the correct category and the time sequence you want, or documents with another category than the one required for the first match.

(category:xyz AND -created[* TO NOW-7DAY/DAY]) OR -category:xyz

Upvotes: 2

Related Questions