Hi,
During some API work I found that when you query for a 'name' with
ListDomains, ListAccounts and/or ListVolumes this search is fuzzy (with
a wildcard).
For example when listing domains:
if (domainName != null) {
sc.setParameters("name", "%" + domainName + "%");
}
Or when listing volumes:
if (name != null) {
sc.setParameters("name", "%" + name + "%");
}
This search is always a wildcard.
So if you want to know if domain 'customerX' exists you query for that,
but your results can also contain 'customerXY' and 'customerXX'.
command=listDomains&name=customerX
I'm taking the listing of domains again and you can also use the
'keyword' parameter like:
command=listDomains&name=customerX&keyword=customerX
When tracing it back to MySQL I see these queries:
* Without keyword *
SELECT domain.id, domain.parent, domain.name, domain.owner, domain.path,
domain.level, domain.removed, domain.child_count, domain.next_child_seq,
domain.state, domain.network_domain, domain.uuid FROM domain WHERE
domain.name LIKE _binary'%customerX%' AND domain.state = 'Active' AND
domain.removed IS NULL ORDER BY domain.id ASC
* With keyword *
SELECT domain.id, domain.parent, domain.name, domain.owner, domain.path,
domain.level, domain.removed, domain.child_count, domain.next_child_seq,
domain.state, domain.network_domain, domain.uuid FROM domain WHERE
domain.name LIKE _binary'%customerX%' AND domain.state = 'Active' AND
(domain.name LIKE _binary'%customerX%' ) AND domain.removed IS NULL
ORDER BY domain.id ASC
I'd like to propose to add a new API parameter in BaseListCmd called
'wildcard'.
By default it is set to true so it behaves like it does now, but you can do:
* true (default): A %LIKE% search
* false: An exact search
* pre: %LIKE search
* post: LIKE% search
This way you can do more exact searching with the API and you don't have
to process all this information on the client.
Would this be an acceptable solution to use for all the list* API calls?
Wido