1

I'm trying to write a lucene query to filter some data in RavenDB. Some of the documents in this specific collection are assigned a sequential number, and the valid ranges are not continuous (for example, one range can be from 100-200 and another from 1000 to 1400). I want to query RavenDB using Raven Studio (v2.5, the Silverlight client) to retrieve all documents that have values outside of these user-defined ranges.

This is the overly simplified document structure:

{  
   ExternalId: something/1,
   SequentialNumber: 12345
}

To test, I added 3500 documents, all of which have a SequentialNumber that's inside one of the following two ranges: 123-312 and 9000-18000, except for one that has 100000123. The ExternalId field is a reference to the parent document, and for this test all the documents have the field set to something/1. This is the Lucene query I came up with:

ExternalId: something/1 AND NOT 
(SequentialNumber: [123 TO 321] OR SequentialNumber: [9000 TO 18000])

Running the query in RavenDB's Studio returns all the documents where SequentialNumber isn't in the 123-321 range. I would expect it to only return the document that has 100000123 as a SequentialNumber. I've been trying to Google for help, but so far I haven't found anything to steer me into the right direction.

What am I doing wrong?

4

1 回答 1

1

RavenDB 以两种方式索引数字,一种是字符串(您在此处看到的),另一种是数字形式。对于范围查询,请使用:

SequentialNumber_Range: [Ix123 TO Ix321] OR SequentialNumber_Range: [Ix9000 TO Ix18000])

Ix 前缀表示您正在使用 int32

于 2015-08-19T17:37:40.847 回答