Umbraco-CMS: Examine index throws error with umbracoNaviHide or any bool field

When doing a search using ExamineManager, (Umbraco 8) when trying to use the umbracoNaviHide or any bool field it throws an error:

Could not perform a range query on the field umbracoNaviHide, it’s value type is Examine.LuceneEngine.Indexing.FullTextType

Reproduction

Bug summary

Create a controller either SurfaceController or RenderMVCControler and add the following code.

if (ExamineManager.Instance.TryGetIndex("ExternalIndex", out var index))
            {

                string[] words = q.Split(' ');


                List<string> newQuery = new List<string>();

                foreach (var word in words)
                {
                    newQuery.Add(word);
                }

                var searcher = index.GetSearcher();
                var results = searcher.CreateQuery("content").GroupedOr(new[] {"pageTitle","pageDescription","pageLayout"}, newQuery.ToArray()).And().Field("umbracoNaviHide", true).Execute(20).OrderByDescending(o=>o.Score).ToList();
                
                //Code removed as not relevant
            }

Change the field params to your own but create a bool either umbracoNaviHide or any other, now run the code and you will get the error.

Change the value of umbracoNaviHide to a string and try again, no error but pages are still returned even when the value is “1”, or “0”.

Expected result

I would expect that if the value is true or false, or “1” or “0”, for that page to not show/show in the results.

Actual result

If you enter a bool true or false you get the error as described if you enter “1” or “0”, all pages are still returned

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Hi @Shazwazza

Thank you for the reply, as I have a custom checkbox that shows ‘Yes’ or ‘No’ with values true or false when parsed by Umbraco worked as a boolean value. Your comment has helped as Examine was looking at the value as a string true, false which explained why using ‘And’ returned zero results.

I have now changed the code to below, note value passed in is now “True”:

var results = searcher.CreateQuery("content").GroupedOr(new[] { "pageTitle", "pageDescription", "pageLayout" }, newQuery.ToArray()).And().Field("includeInSiteSearch", "True").Execute(20).OrderByDescending(o => o.Score).ToList();

The above now works as expected.

My apologies for thinking this was a bug

Regards George