Adding Eli ...
On Mon, Aug 1, 2016 at 12:35 PM, Ondra Machacek <omachace(a)redhat.com> wrote:
On 08/01/2016 12:26 PM, 转圈圈 wrote:
> This is a different meaning.
>
> List<Vm> vms = vmsService.list().search("name=myvm1 or comment=myvm and
> status=up").send().vms();
> SQL statement: select * from vms where name = 'myvm1' or
comment='myvm'
> and status = up
>
> List<Vm> vms = vmsService.list().search("(name=myvm1 or comment=myvm)
> and status=up").send().vms();
> SQL statement: select * from vms where (name = 'myvm1'
> or comment='myvm') and status = up
>
> Query result are different.
> I want the SQL statement: select * from vms where (name = 'myvm1'
> or comment='myvm') and status = up
>
oVirt search pattern is not 100% mapped to SQL query,
so as I said, your query should work for you as expected without braces.
Eli, can elaborate more for you, what's supported or not in oVirt search
patterns, if needed.
>
> ------------------ 原始邮件 ------------------
> *发件人:* "Ondra Machacek";<omachace(a)redhat.com>;
> *发送时间:* 2016年8月1日(星期一) 晚上6:18
> *收件人:* "转圈圈"<313922611(a)qq.com>;
> *抄送:* "users@ovirt.org"<users(a)ovirt.org>;
> *主题:* Re: 回复: 回复: 回复: [ovirt-users]
> ovirt-engine-java-sdk-4.0: How fuzzy query
>
> 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(a)redhat.com>;
>> *发送时间:* 2016年8月1日(星期一) 下午5:31
>> *收件人:* "转圈圈"<313922611(a)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(a)redhat.com>;
>>> *发送时间:* 2016年8月1日(星期一) 下午5:18
>>> *收件人:* "转圈圈"<313922611(a)qq.com>;
>>> *抄送:* "users@ovirt.org"<users(a)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(a)redhat.com>;
>>>> *发送时间:* 2016年8月1日(星期一) 下午4:37
>>>> *收件人:* "转圈圈"<313922611(a)qq.com>;
"users"<users(a)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(a)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/j...
>
_______________________________________________
Users mailing list
Users(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/users