LuceneQuery<> and NULL and NOT NULL queries

7,409 views
Skip to first unread message

Johan Nordberg

unread,
Jan 26, 2012, 8:23:54 AM1/26/12
to rav...@googlegroups.com
What's the best way of dong IsNull and IsNotNull queries with a LuceneQuery<>?

I'd like to list Posts where Media Is Not Null, but where Media.Video Is Null.

So, I need the Lucene-version of this:

session.Query<Post>()
    .Where(x => x.Media != null && x.Media.Video == null)


I think I need to use a LuceneQuery because I need to sort by using a string variable, not a lambda.

Oren Eini (Ayende Rahien)

unread,
Jan 26, 2012, 8:30:45 AM1/26/12
to rav...@googlegroups.com
Media.Video:[[NULL_VALUE]] 

Note that you don't need to check that media is not null to access the video

Johan Nordberg

unread,
Jan 26, 2012, 9:15:21 AM1/26/12
to rav...@googlegroups.com
Thanks!

But I actually want to make sure that Media is not null as a part of my filter. I just want the documents that has some a Media, but not Media.Video. It's a query like "give me all emails that has an attachment, but I don't want this special kind of attachment".


Oren Eini (Ayende Rahien)

unread,
Jan 26, 2012, 9:19:44 AM1/26/12
to rav...@googlegroups.com
Media.Video:[[NULL_VALUE]] AND  -Media:[[NULL_VALUE]]

Johan Nordberg

unread,
Jan 26, 2012, 9:49:55 AM1/26/12
to rav...@googlegroups.com
Almost too simple. :)

Thanks a lot!

sandip...@gmail.com

unread,
Mar 1, 2019, 10:03:03 AM3/1/19
to RavenDB - 2nd generation document database
Hi Oren Eini,
  Can you please send live example of null check, because I am using QueryParser to create the lucene query. So how can I create the lucene query for this scenario? 
Please reply me...

Oren Eini (Ayende Rahien)

unread,
Mar 3, 2019, 2:05:37 AM3/3/19
to ravendb
This is from a thread in 2012
Please create a new thread with full details

--
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.


--
Oren Eini
CEO   /   Hibernating Rhinos LTD
Skype:  ayenderahien
Support:  sup...@ravendb.net
Reply all
Reply to author
Forward
0 new messages