Index as numeric fields using Sitecore advanced crawler

I needed to search for a price field using a lucene range query. However, the results obtained are not accurate or consistent as I am using TermRangeQuery in the Lucene.Net API. I believe that by using NumericRangeQuery I could get accurate results. To use NumericRangeQuery, the field must be indexed using a NumericField. Is there any way to do this with Advanced Database Crawler. I tried to do this by modifying the Advanced Database Crawler source code, but it doesn't work for me.

These are the changes I made to Advanced Database Crawler. In the scSearchContrib.Crawler.Crawlers.AdvancedDatabaseCrawler class, in the CreateField method, I've added the following code.

if (name.EndsWith("numeric"))
{
    field = new NumericField(name, storageType, true);
}

      

in the index configuration, I gave the field name and added the text "numeric" to it. However, I am passing the field name correctly by removing the "numeric" part.

when creating the index, I get this error.

Job started: RebuildSearchIndex|System.NullReferenceException: Object reference not set to an instance of an object.
   at Lucene.Net.Store.IndexOutput.WriteString(String s)
   at Lucene.Net.Index.FieldsWriter.WriteField(FieldInfo fi, Fieldable field)
   at Lucene.Net.Index.StoredFieldsWriterPerThread.AddField(Fieldable field, FieldInfo fieldInfo)
   at Lucene.Net.Index.DocFieldProcessorPerThread.ProcessDocument()
   at Lucene.Net.Index.DocumentsWriter.UpdateDocument(Document doc, Analyzer analyzer, Term delTerm)
   at Lucene.Net.Index.DocumentsWriter.AddDocument(Document doc, Analyzer analyzer)
   at Lucene.Net.Index.IndexWriter.AddDocument(Document doc, Analyzer analyzer)
   at Lucene.Net.Index.IndexWriter.AddDocument(Document doc)
   at Sitecore.Search.IndexUpdateContext.AddDocument(Document document)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddItem(Item item, IndexUpdateContext context)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddTree(Item root, IndexUpdateContext context)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddTree(Item root, IndexUpdateContext context)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddTree(Item root, IndexUpdateContext context)
   at Sitecore.Search.Index.Rebuild()
   at Sitecore.Shell.Applications.Search.RebuildSearchIndex.RebuildSearchIndexForm.Builder.Build()|Job ended: RebuildSearchIndex (units processed: 1)

      

Can anyone tell me a way to do this using Advanced Database Crawler?

Thanks in Advance

+3


source to share


1 answer


Even though I couldn't index like a numeric field, I found a job for the problem. It must be indexed with padded zeros, so lucene TermRangeQuery gives correct search results. Each price is indexed with filled zeros, so each value will contain 10 digits. Thus, the results I get are accurate.



+3


source







All Articles