Numeric range search or numerical search allows you to search in documents any integer numbers in the range from 0 to 9223372036854775807 (Long.MAX_VALUE). Please note that the number in the text must not be separated by spaces, otherwise it will already be several numbers. A search query of this type is specified as follows:
number ~~ number
The example below demonstrates the numeric range search in text and object forms.
StringindexFolder="c:\\MyIndex\\";StringdocumentsFolder="c:\\MyDocuments\\";// Creating an index in the specified folder
Indexindex=newIndex(indexFolder);// Indexing documents from the specified folder
index.add(documentsFolder);// Search with text query
SearchResultresult1=index.search("500 ~~ 600");// Search with object query
SearchQueryquery2=SearchQuery.createNumericRangeQuery(500,600);SearchResultresult2=index.search(query2);
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: