question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Examine index throws error with umbracoNaviHide or any bool field

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
GeorgePhillipsoncommented, Oct 28, 2019

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

0reactions
GeorgePhillipsoncommented, Oct 28, 2019

Hi @Shazwazza

Thank you

Regards George

Read more comments on GitHub >

github_iconTop Results From Across the Web

examine index problem - General
hey, i'm getting error from Examine. The indexSet specified for the LuceneExamineIndexer provider does not exist. ExamineSettings. <Examine>
Read more >
Is Examine search ignoring certain keywords or my query ...
I am building Examine search in Umbraco and am searching by either keyword or country code or city but I am getting wrong...
Read more >
Unable to populate boolean field from index value
My Lucene web Index is correctly populated with the field parsed_is_line_manager . In the BasePerson class, I thus added this field:
Read more >
Boolean field type | Elasticsearch Guide [8.9]
Trying to index the wrong data type into a field throws an exception by default, and rejects the whole document. If this parameter...
Read more >
Boolean field type
A Boolean value that specifies whether the field should be stored on disk so that it can be used for aggregations, sorting or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found