0
votes

I'm using Umbraco v.7.6.1 with Examine v0.1.82 (Lucene 2.9.4.1). I have a list of vehicles and a search form to query different types of fields, including Price. The Price field is a Numeric data field and in the ExamineIndex is defined as:

<add Name="price" Type="INT" />

The problem is when searching for a price range, I have no results. Using the Examine Management tool in the Umbraco backoffice with the following query:

+price:[50 TO 500000]

returns no results, even though I have vehicles in that price range.

If I change the Examine index and remove the Type="INT" tag from the price field, then the range query works as a normal string range query and returns results.

The query is working properly for all the string fields.

According to everything I've read in the documentation and previous questions/answers about Examine, this should work with the Examine version I'm using. What could be wrong?

1

1 Answers

2
votes

I guess you are looking in the back office after setting it to INT in ExamineIndex.config file under IndexUserFields. Back office will not show result for it if you pass straight query. I faced the same thing. You have to query throw code and it will show up the result.

Kindly set <add Name="price" Type="Int" /> in the config file. I hope case wont have any issue like INT or Int.

Then Query from the code is like below

var searcher = Examine.ExamineManager.Instance.SearchProviderCollection["SearcherName"];
var searchCriteria = searcher.CreateSearchCriteria();

var query = searchCriteria.Range("price", 50, 500000, true, true);
var results = searcher.Search(query.Compile());

Kindly rebuild index before querying.