How to exclude search results based on condition?

Now my question I need to exclude search results based on the value containing on the particular field .If field doesn't have the value it should display all results.

I don't know of a way to do this, but someone else might have something they can suggest.