Decimal Range Search Query Over LUCENE FULLTEXT INDEX (Orientdb / Lucene)

188 Views Asked by At

I store the all kind of value(Integer, Flot, Date, Text, etc...) in a column "Custom" which is a datatype of STRING. How to do an Integer range search query on column "custom" using Lucene?

something like:- select * from CustomTable where Custom:[1 TO 100];

I have one solution append zero in beginning but looking for some alternative solution?

I am very new to Lucene search

1

There are 1 best solutions below

0
Roberto  Franchini On

My suggestion is to read carefully the documentation about Lucene indexes in Orientdb, and especially the section about range queries:

http://orientdb.com/docs/3.0.x/indexing/Full-Text-Index.html#numeric-and-date-range-queries

The docs explain a bit how an inverted index works.

BTW, the example is straightforward:

CREATE CLASS CITY EXTENDS V
CREATE PROPERTY CITY.name STRING
CREATE PROPERTY CITY.size INTEGER
CREATE INDEX City.name ON City(name,size) FULLTEXT ENGINE LUCENE

"size" is declared as integer, than you can use range query:

SELECT FROM City WHERE SEARCH_CLASS('name:cas* AND size:[15000 TO 20000]') = true

The same happens with dates: define them properly in the schema and query for ranges using lucene queries