Lucene Indexing NumericFiled bug

Topics: Core, Troubleshooting, Writing modules
Aug 18, 2012 at 9:18 PM

If create NumericFiled for ContentType and indexing it by Lucene (from dashboard)

Then it was indexing as string utf8 and i can't use WithinRange function Orchard.Indexing.ISearchBuilder class.

How can i fix it?

Aug 18, 2012 at 10:13 PM
Edited Aug 18, 2012 at 10:24 PM

Solution: change Orchard.Indexing.Handlers.InfosetFieldIndexingHandler

from

 

context.DocumentIndex.Add(String.Format("{0}-{1}", infosetPart.TypeDefinition.Name.ToLower(), fieldName.ToLower()), value).RemoveTags().Analyze();

 

to

 

if (field.FieldDefinition.Name == "NumericField")
{
	double doubleValue = 0;
        if(Double.TryParse(value, out doubleValue))
        {
        	context.DocumentIndex.Add(String.Format("{0}-{1}", infosetPart.TypeDefinition.Name.ToLower(), fieldName.ToLower()), doubleValue).RemoveTags().Analyze();
        }
}
else
{
	context.DocumentIndex.Add(String.Format("{0}-{1}", infosetPart.TypeDefinition.Name.ToLower(), fieldName.ToLower()), value).RemoveTags().Analyze();
}
Sep 3, 2013 at 6:31 PM
I'm having the same issue with orchard 1.7, but I think the code has in the InfosetFieldIndexingHandler class has changed since then. Is the solution is relevant to the problem?
Coordinator
Sep 3, 2013 at 7:00 PM
As I read the new code, there shouldn't be any issue actually. If you think there is one, please file a bug with the repro steps.
Coordinator
Sep 4, 2013 at 6:25 PM
Ok, I found the bug, fixing it right now.

It happens on Boolean too (nullable in the field), and the enumeration has a related issue. I will have to come up with a new way to index complex value.
Sep 4, 2013 at 6:35 PM
Good to know its not just me.
Sep 9, 2013 at 5:35 PM
Coordinator
Sep 9, 2013 at 6:33 PM
Yes