Range query not works

153 views
Skip to first unread message

Mouhong Lin

unread,
Jul 14, 2012, 8:44:43 AM7/14/12
to rav...@googlegroups.com
Hi guys,

I'm using RavenDB build 960. For range queries, it seems that only WhereEquals works:

session.Advanced.LuceneQuery<Microblog, MicroblogIndex>().WhereLessThan("CommentCount", 13); // Not work
session.Advanced.LuceneQuery<Microblog, MicroblogIndex>().WhereEquals("CommentCount", 13);     // Works


Thanks in advance!

Itamar Syn-Hershko

unread,
Jul 14, 2012, 2:00:14 PM7/14/12
to rav...@googlegroups.com
session.Advanced.LuceneQuery<Microblog, MicroblogIndex>().WhereLessThan("CommentCount_Range", 13); 

linmo...@gmail.com

unread,
Jul 14, 2012, 2:13:28 PM7/14/12
to ravendb
I've tried using "CommentCount_Range", but it's no difference, still returns empty result. You can try my gist (using RavenDB build 960).
 

Itamar Syn-Hershko

unread,
Jul 14, 2012, 3:58:04 PM7/14/12
to rav...@googlegroups.com
Remove this line:  Index(it => it.CommentCount, Raven.Abstractions.Indexing.FieldIndexing.NotAnalyzed);

linmo...@gmail.com

unread,
Jul 15, 2012, 12:06:57 AM7/15/12
to ravendb
Thanks, this works. But why do I need to remove this line? Is there some document about this?

Oren Eini (Ayende Rahien)

unread,
Jul 15, 2012, 3:00:58 AM7/15/12
to rav...@googlegroups.com
The docs are in here:

The reason you need to remove it because when you specify this you say to RavenDB, just allow me to search on this field as is, I don't want to do anything else to it.

linmo...@gmail.com

unread,
Jul 15, 2012, 4:01:53 AM7/15/12
to ravendb
Thanks, I think I have to read the whole documents. :-)
 
I think this will sometimes confuse people. Because for some fields you MUST call Index method (otherwise you can not query on it), while for other fields you should NOT call Index (otherwise you can not do range query on it). Will this make the semantic of the Index method not clear?
 
Another question, about the Sort method in Index creation class.
I think it's possible for RavenDB to detect the field data type?
I mean, as a RavenDB user, when I index an Int32 field, I would expect that RavenDB can treat it as an Int field automatically, and set the sort field data type to Int.
Yes, I can specify the sort field data type myself by calling Sort(...) method, but for int fields, I will expect Int as default sort data type.
(If I want to override this setting, then I can call Sort method explicitly)
Why RavenDB doesn't do this? Is there other design decisions? Thanks :-)
 
 

Oren Eini (Ayende Rahien)

unread,
Jul 15, 2012, 4:10:16 AM7/15/12
to rav...@googlegroups.com
inline

On Sun, Jul 15, 2012 at 11:01 AM, linmo...@gmail.com <linmo...@gmail.com> wrote:
Thanks, I think I have to read the whole documents. :-)
 
I think this will sometimes confuse people. Because for some fields you MUST call Index method (otherwise you can not query on it), while for other fields you should NOT call Index (otherwise you can not do range query on it). Will this make the semantic of the Index method not clear?
 

In general, you need to call Index() only when you want full text search or really know what you are doing.
 
Another question, about the Sort method in Index creation class.
I think it's possible for RavenDB to detect the field data type?
It does, that is why you can use _Range
 
I mean, as a RavenDB user, when I index an Int32 field, I would expect that RavenDB can treat it as an Int field automatically, and set the sort field data type to Int.
Yes, I can specify the sort field data type myself by calling Sort(...) method, but for int fields, I will expect Int as default sort data type.
(If I want to override this setting, then I can call Sort method explicitly)
Why RavenDB doesn't do this? Is there other design decisions? Thanks :-)

We can't assume consistent serialization. You may have something like "1" that you want to index as int.
And we do the auto stuff in the _Range variable.
Reply all
Reply to author
Forward
0 new messages