Not contains query 2.5 #2962

46 views
Skip to first unread message

Derek den Haas

unread,
Jun 26, 2015, 2:41:18 AM6/26/15
to rav...@googlegroups.com
I was trying to do a query not containing an item in a list.

I can use:
!.Contains( item ), 
-- which should be converted to -EventsTodo: Postpone) 
----- should do the job
.Any( != )
-- which should be converted to -EventsTodo: Postpone && EventsTodo:*
----- Will work BUT not when the list is empty, so this is a no go

!.Any() isn't supported

Index mapping:
{
    bool IsDebet,
    bool Done,
    bool Payed,
    IEnumerable<InvoiceEvents> EventsTodo,
    string PaymentMethodId
}

When doing:
                        .Where(a =>
                            a.IsDebet &&
                            a.Done &&
                            !a.Payed &&
                            !a.EventsTodo.Contains(InvoiceEvents.Postpone) &&
                            a.PaymentMethodId.In(model.PaymentMethods))


I will get:
(((IsDebet:true AND Done:true) AND Payed:false) AND (*:* AND)) AND -@in<PaymentMethodId>:(PaymentMethods/33,PaymentMethods/34)

Please note that it added a dash to the @in<> which makes the outcome even worse :)


Yes I could change the mapping to:
Index mapping:
{
    bool IsDebet,
    bool Done,
    bool Payed,
    string EventsTodo,
    string PaymentMethodId
}

But I dislike the solution, except if the above isn't supported, then I'll have to convert it.

Oren Eini (Ayende Rahien)

unread,
Jun 28, 2015, 4:06:35 AM6/28/15
to ravendb
I don't follow. Can you show a failing test?

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Derek den Haas

unread,
Jun 28, 2015, 8:48:38 AM6/28/15
to rav...@googlegroups.com
!a.EventsTodo.Contains(InvoiceEvents.Postpone) will be translated to:

(*:* AND)

Making a non valid query.

The "NOT" (!) will be added to the next statement.

So this:
                        .Where(a =>
                            !a.EventsTodo.Contains(InvoiceEvents.Postpone) &&
                            a.PaymentMethodId.In(model.PaymentMethods))


Is currently translated to:
(*:* AND) AND -@in<PaymentMethodId>:(PaymentMethods/33,PaymentMethods/34)

If I do something unsupported, please correct me.

Op zondag 28 juni 2015 10:06:35 UTC+2 schreef Oren Eini:

Oren Eini (Ayende Rahien)

unread,
Jun 28, 2015, 9:25:04 AM6/28/15
to ravendb
What is the content of Postphone?

Tal Weiss

unread,
Jun 28, 2015, 9:34:50 AM6/28/15
to rav...@googlegroups.com
i'm sorry but this is not the current lucene query...
.Where(a =>
                            !a.EventsTodo.Contains(InvoiceEvents.Postpone) &&
                            a.PaymentMethodId.In(model.PaymentMethods))
should be:
(*:* AND -@in<EventsTodo>:(<value of InvoiceEvents.Postpone>)) AND @in<PaymentMethodId>:(PaymentMethods/33,PaymentMethods/34)

note that the '-' is place on the wrong clause and also there is no mention of EventsTodo

Hibernating Rhinos Ltd  cid:image001.png@01CF95E2.8ED1B7D0

Tal Weiss l Core Team Developer Mobile:+972-54-802-4849

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811l Skype: talweiss1982

RavenDB paving the way to "Data Made Simplehttp://ravendb.net/ 

Tal Weiss

unread,
Jun 28, 2015, 9:36:28 AM6/28/15
to rav...@googlegroups.com
it seems like something went wrong in the translation of :
a.EventsTodo.Contains(InvoiceEvents.Postpone)

Derek den Haas

unread,
Jun 28, 2015, 9:53:37 AM6/28/15
to rav...@googlegroups.com
It's an enum

Op zondag 28 juni 2015 15:25:04 UTC+2 schreef Oren Eini:

Derek den Haas

unread,
Jun 28, 2015, 9:55:10 AM6/28/15
to rav...@googlegroups.com
To add some details:

Index mapping:
{
    bool IsDebet,
    bool Done,
    bool Payed,
    IEnumerable<InvoiceEvents> EventsTodo,
    string PaymentMethodId
}

public enum InvoiceEvents {
    Postpone,
    Done
}

Op zondag 28 juni 2015 15:53:37 UTC+2 schreef Derek den Haas:

Tal Weiss

unread,
Jun 28, 2015, 10:28:39 AM6/28/15
to rav...@googlegroups.com
i was wrong the contains should be translated to EventsTodo:InvoiceEvents.Postpone
And EventsTodo should have multiple values in the index so the query should look like:
(*:* AND -EventsTodo:InvoiceEvents.Postpone) AND @in<PaymentMethodId>:(PaymentMethods/33,PaymentMethods/34)

Derek den Haas

unread,
Jun 28, 2015, 11:11:31 AM6/28/15
to rav...@googlegroups.com
It should be translated to (*:* AND -EventsTodo:Postpone)

(without the name of the enum (invoiceEvents))

When I check the output of the created Lucene, it will read as above (*:* AND) -@in

Op zondag 28 juni 2015 16:28:39 UTC+2 schreef Tal Weiss:
Reply all
Reply to author
Forward
0 new messages