refs 4873 create valid search query with AND/OR