Bug 1402799 - Search and filtering don't work well together: empty results
Summary: Search and filtering don't work well together: empty results
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: RestAPI
Version: 4.0.6.1
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ovirt-4.1.0-rc
: 4.1.0
Assignee: Juan Hernández
QA Contact: Aleksei Slaikovskii
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-12-08 11:25 UTC by Juan Hernández
Modified: 2020-03-11 15:33 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-02-01 14:53:32 UTC
oVirt Team: Infra
Embargoed:
rule-engine: ovirt-4.0.z+
rule-engine: ovirt-4.1+
mgoldboi: planning_ack+
juan.hernandez: devel_ack+
pstehlik: testing_ack+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 67526 0 master MERGED restapi: Use ids to calculate intersections 2020-10-26 20:16:08 UTC
oVirt gerrit 68775 0 ovirt-engine-4.1 MERGED restapi: Use ids to calculate intersections 2020-10-26 20:16:09 UTC
oVirt gerrit 68904 0 ovirt-engine-4.0 MERGED restapi: Use ids to calculate intersections 2020-10-26 20:16:09 UTC

Description Juan Hernández 2016-12-08 11:25:59 UTC
The API has the capability to perform searches, using the 'search' query parameter:

  GET /ovirt-engine/api/vms?search=name%3Dmyvm

It also has the capability to filter results according to the permissions of the user, using the 'filter' parameter (or the 'Filter' http header):

  GET /ovirt-engine/api/vms?filter=true

The can be used together as well:

  GET /ovirt-engine/api/vms?search=name%3Dmyvm&filter=true

When doing this, using them together, the implementation performs two separate queries, one for searching and another one for filtering, and then calculates the intersection of the results. But this calculation is computed comparing the objects using the Java Object.equals method. This means that minor differences in the results, like an attribute that isn't populated, will result in excluding that particular result from the intersection. The net result perceived by the user of the API is that the intersection is usually empty. To avoid that we need to calculate the intersection using only the identifiers of the objects.

Comment 1 Sandro Bonazzola 2017-01-25 07:54:17 UTC
4.0.6 has been the last oVirt 4.0 release, please re-target this bug.

Comment 2 Aleksei Slaikovskii 2017-01-30 16:20:01 UTC
Verified on ovirt-engine-4.1.1-0.0.master.

➜  ~ curl -s -k -X GET -u admin@internal:123456 -H "Accept: application/json" https://engine/ovirt-engine/api/vms | grep 123
    "name" : "123",

➜  ~ curl -s -k -X GET -u admin@internal:123456 -H "Accept: application/json" https://engine/ovirt-engine/api/vms\?search\=name\=123 | grep 123
    "name" : "123",

➜  ~ curl -s -k -X GET -u admin@internal:123456 -H "Accept: application/json" https://engine/ovirt-engine/api/vms\?filter\=true | grep 123
    "name" : "123",

➜  ~ curl -s -k -X GET -u admin@internal:123456 -H "Accept: application/json" https://engine/ovirt-engine/api/vms\?search\=name\=123\&filter\=true | grep 123
    "name" : "123",


Note You need to log in before you can comment on or make changes to this bug.