Repository: conan-io/conan

Issue:
Conan Search query broken
To help us debug your issue please explain:

- [ x ] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).
- [ x ] I've specified the Conan version, operating system version and any tool that can be relevant.
- [ x ] I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.

Conan version 1.14.1, 1.12.3, 1.11.2, 1.13.1
OS: Linux (Ubuntu 16.04 / Fedora 29)
Artifactory Server Version 6.9.0

Conan search doesn't work as expected since the Upgrade of our Artifactory server:

Works:
`conan search my-product/1.0.0@usr/stable -q "build_type=Release AND os=Windows" -r releases
`
Doesn't work:
`conan search my-product/1.0.0@usr/stable -q "(build_type=Release AND os=Windows) OR os=Linux" -r releases`

`ERROR: Unknown query key: (build_type. [Remote: releases]`

And with more complex Queries I get an different error:

`ERROR: Unexpected query syntax: (os=Windows OR os=Linux OR os=any OR os=None) AND ((compiler=gcc AND compiler.version=5.4) OR (compiler="Visual Studio" AND compiler.version=14) OR compiler=any OR compiler=Any OR compiler=None) AND (arch=any OR arch=x86_64 OR arch=None) AND (arch_build=x86_64 OR arch_build=None OR arch_build=any). [Remote: releases]
`

The Errors appeared first after upgrading the Artifactory Server and the queries are still working on Artifactory Server Versions 6.5.2 and 6.8.4.


Discussion:
Confirmed it is not working anymore in Artifactory 6.9, and it worked with Artifactory 6.3.
It is not fixed in Artifactory 6.9.1.

I have tested with Artifactory CE


Reported in Artifactory: https://www.jfrog.com/jira/browse/RTFACT-18952
Will this be fixed in 6.9.2? This bug is really blocking us
I don't know. If possible, please try to upvote the JIRA ticket: https://www.jfrog.com/jira/browse/RTFACT-18952
Also not working with options with artifactory/bintray, but works when using on local cache.
```
$ conan search zlib/1.2.11@conan/stable -r=conan-center -q "shared=False"
ERROR: Unknown query key: shared. [Remote: conan-center]

$ conan search zlib/1.2.11@conan/stable -q "shared=False"
Existing packages for recipe zlib/1.2.11@conan/stable:
...
```
Are there any news concerning this bug? The JIRA ticket seems abandoned
Hi @mietzen no news at the moment, ping @markgalpin 
Hi @mietzen 

Sorry for the delay. We are disabling this search in the server side in #5960, and falling back to the filtering in the client side (which was the behavior that was actually being used before the upgrade to Artifactory 6.9).

This fix will be available in Conan 1.20, to be released next week. Please tell me if this is good for you, or you would need something else. Thanks!

Resolving patch:
diff --git a/conans/client/rest/rest_client.py b/conans/client/rest/rest_client.py
--- a/conans/client/rest/rest_client.py
+++ b/conans/client/rest/rest_client.py
@@ -1,6 +1,4 @@
-from collections import defaultdict
-
-from conans import CHECKSUM_DEPLOY, REVISIONS, ONLY_V2, OAUTH_TOKEN, COMPLEX_SEARCH_CAPABILITY
+from conans import CHECKSUM_DEPLOY, REVISIONS, ONLY_V2, OAUTH_TOKEN
 from conans.client.rest.rest_client_v1 import RestV1Methods
 from conans.client.rest.rest_client_v2 import RestV2Methods
 from conans.errors import OnlyV2Available
@@ -110,11 +108,10 @@ def search(self, pattern=None, ignorecase=True):
         return self._get_api().search(pattern, ignorecase)
 
     def search_packages(self, reference, query):
-        package_infos = self._get_api().search_packages(reference, query)
-        if query and COMPLEX_SEARCH_CAPABILITY not in self._cached_capabilities.get(self.remote_url,
-                                                                                    []):
-            return filter_packages(query, package_infos)
-        return package_infos
+        # Do not send the query to the server, as it will fail
+        # https://github.com/conan-io/conan/issues/4951
+        package_infos = self._get_api().search_packages(reference, query=None)
+        return filter_packages(query, package_infos)
 
     def remove_conanfile(self, ref):
         return self._get_api().remove_conanfile(ref)


Test patch:
diff --git a/conans/test/functional/command/search_test.py b/conans/test/functional/command/search_test.py
--- a/conans/test/functional/command/search_test.py
+++ b/conans/test/functional/command/search_test.py
@@ -8,14 +8,13 @@
 
 from mock import patch
 
-from conans import COMPLEX_SEARCH_CAPABILITY, DEFAULT_REVISION_V1
+from conans import DEFAULT_REVISION_V1
 from conans.model.manifest import FileTreeManifest
 from conans.model.package_metadata import PackageMetadata
 from conans.model.ref import ConanFileReference, PackageReference
 from conans.paths import CONANINFO, EXPORT_FOLDER, PACKAGES_FOLDER
 from conans.server.revision_list import RevisionList
-from conans.test.utils.tools import TestClient, TestServer, NO_SETTINGS_PACKAGE_ID, TurboTestClient, \
-    GenConanfile
+from conans.test.utils.tools import TestClient, TestServer, NO_SETTINGS_PACKAGE_ID, GenConanfile
 from conans.util.dates import iso8601_to_str, from_timestamp_to_iso8601
 from conans.util.env_reader import get_env
 from conans.util.files import list_folder_subdirs, load
@@ -133,7 +132,7 @@ class SearchTest(unittest.TestCase):
     def setUp(self):
         self.servers = OrderedDict()
         self.servers["local"] = TestServer(server_capabilities=[])
-        self.servers["search_able"] = TestServer(server_capabilities=[COMPLEX_SEARCH_CAPABILITY])
+        self.servers["search_able"] = TestServer(server_capabilities=[])
 
         self.client = TestClient(servers=self.servers)