RavenDB 4 - Querying for NULL in Lucene

141 views
Skip to first unread message

Andrej Krivulčík

unread,
May 15, 2018, 9:53:12 AM5/15/18
to RavenDB - 2nd generation document database
Is it possible to query for NULL when using Lucene in RavenDB 4?

Using [[NULL_VALUE]] doesn't work anymore:
  • from index 'DocsIndex' where lucene("StrVal", "StrVal:[[NULL_VALUE]]")
    • Lucene.Net.QueryParsers.ParseException: Cannot parse 'StrVal:[[NULL_VALUE]]': Encountered " "]" "] "" at line 1, column 19.
      Was expecting one of:
          "TO" ...
          <RANGEIN_QUOTED> ...
          <RANGEIN_GOOP> ...
It would be useful for achieving this: https://groups.google.com/forum/#!topic/ravendb/5JVjUgWm6jw

Oren Eini (Ayende Rahien)

unread,
May 15, 2018, 9:59:02 AM5/15/18
to ravendb
where exact(Name = 'NULL_VALUE')

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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrej Krivulčík

unread,
May 15, 2018, 10:04:53 AM5/15/18
to RavenDB - 2nd generation document database
This isn't lucene thought, is it? I need to boost the value of not null values. In 3.5 it used to be something like:

((*:* AND StrVal:[[NULL_VALUE]])^100) OR (StrVal:[[NULL_VALUE]])

and then .OrderByScore(), to have null values always last.

So I'm looking for ways to do something similar in RavenDB 4.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

Andrej Krivulčík

unread,
May 15, 2018, 10:21:00 AM5/15/18
to RavenDB - 2nd generation document database
Sorry, I dropped a minus sign there, it should be:

((*:* AND -StrVal:[[NULL_VALUE]])^100) OR (StrVal:[[NULL_VALUE]])

Oren Eini (Ayende Rahien)

unread,
May 15, 2018, 10:44:27 AM5/15/18
to ravendb

How about this?

        
public class DocsIndex : AbstractIndexCreationTask<Doc>
        
{
            
public DocsIndex()
            
{
                
Map = docs =>
                    
from doc in docs
                    
select new
                    
{
                        doc
.Id,
                        doc
.StrVal ?? "zzzz",
                        doc
.IntVal ?? long.MaxValue
                    
};
            
}
        
}
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Andrej Krivulčík

unread,
May 15, 2018, 10:47:17 AM5/15/18
to RavenDB - 2nd generation document database
Well, this is something like using [[NULL_VALUE]], having a special value we'd need to boost using the lucene query. If querying NULL_VALUE is not possible in lucene queries, I'll have to resort to something similar.
Reply all
Reply to author
Forward
0 new messages