Lucene.Net range subquery not returning expected results (RavenDB related)

妖精的绣舞 提交于 2019-12-11 12:52:38

问题


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?


回答1:


RavenDB is indexing numbers in two ways, once as strings (which is what you see here) and once in numeric form. For range queries use:

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

The Ix prefix means that you are using int32



来源:https://stackoverflow.com/questions/32101801/lucene-net-range-subquery-not-returning-expected-results-ravendb-related

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!