[ovirt-users] 回复: 回复: 回复: ovirt-engine-java-sdk-4.0: How fuzzy query

Ondra Machacek omachace at redhat.com
Mon Aug 1 06:18:01 EDT 2016


On 08/01/2016 11:38 AM, 转圈圈 wrote:
> thanks.
>    for example:
>         SQL statement:   select * from vms where (name = 'myvm1' or
> comment='myvm') and  status = up
>    using SDK, created for by 'search':
>         List<Vm> vms = vmsService.list().search("(name=myvm1 or
> comment=myvm) and status=up").send().vms();
>    The above is wrong,how to do?

Just remove brackets:

   List<Vm> vms = vmsService.list().search("name=myvm1 or comment=myvm 
and status=up").send().vms();

It's not needed in this case.

>
>
>
> ------------------ 原始邮件 ------------------
> *发件人:* "Ondra Machacek";<omachace at redhat.com>;
> *发送时间:* 2016年8月1日(星期一) 下午5:31
> *收件人:* "转圈圈"<313922611 at qq.com>;
> *主题:* Re: 回复: 回复: [ovirt-users] ovirt-engine-java-sdk-4.0: How
> fuzzy query
>
> On 08/01/2016 11:22 AM, 转圈圈 wrote:
>> thanks.
>> The above is wrong.
>> if i want to use "like",how to do?
>
> You can use star, so for example this:
>
>    Vm vm = vmsService.list().search("name=myvm*").send().vms().get(0);
>
> Will find for you myvm1,myvm2, etc
>
>>
>>
>> ------------------ 原始邮件 ------------------
>> *发件人:* "Ondra Machacek";<omachace at redhat.com>;
>> *发送时间:* 2016年8月1日(星期一) 下午5:18
>> *收件人:* "转圈圈"<313922611 at qq.com>;
>> *抄送:* "users at ovirt.org"<users at ovirt.org>;
>> *主题:* Re: 回复: [ovirt-users] ovirt-engine-java-sdk-4.0: How fuzzy
> query
>>
>> On 08/01/2016 11:06 AM, 转圈圈 wrote:
>>> thanks.
>>>     for example:
>>>        List<Vm> vms =
>>> systemService.vmsService().list().search("search=name=myvm and
>>> status=up").send().vms();
>>> but I use query conditions "and" ,have no result.why?
>>
>> Oh, sorry I meant you have to use 'search=' in case of using API,
>> so URL looks like: fqdn/ovirt-engine/api/vms?search=name=myvm and
>> status=down
>>
>> But in case of using SDK, the 'search=' is created for you by 'search'
>> method, so
>> this should actually work for you:
>>
>>    Vm vm = systemService().vmsService.list().search("name=myvm and
>> status=up").send().vms().get(0);
>>
>>>
>>>
>>>
>>> ------------------ 原始邮件 ------------------
>>> *发件人:* "Ondra Machacek";<omachace at redhat.com>;
>>> *发送时间:* 2016年8月1日(星期一) 下午4:37
>>> *收件人:* "转圈圈"<313922611 at qq.com>; "users"<users at ovirt.org>;
>>> *主题:* Re: [ovirt-users] ovirt-engine-java-sdk-4.0: How fuzzy query
>>>
>>> On 08/01/2016 07:13 AM, 转圈圈 wrote:
>>>> The above code is wrong,how fuzzy query?
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at ovirt.org
>>>> http://lists.ovirt.org/mailman/listinfo/users
>>>>
>>>
>>> You need to prefix with 'search=',
>>> So for example to search by name or status, you should have something
>> like:
>>>
>>>     ....list().search("search=name=myvm or status=up").send()....
>>>
>>> You can check examples here:
>>>
>>>
>>>
>>
> https://github.com/oVirt/ovirt-engine-sdk-java/tree/master/sdk/src/test/java/org/ovirt/engine/sdk4/examples


More information about the Users mailing list