3

I needed to search a price field using lucene range query. However the results it gives are not accurate or consistent since I am using a TermRangeQuery in Lucene.Net API. I believe that using NumericRangeQuery I could get accurate results. To use NumericRangeQuery the field needs to be indexed using NumericField. Is there a way I can do this with Advanced Database Crawler. I tried to do this by altering the Advanced Database Crawler source code but it is not working for me.

These are the changes I have done in Advanced Database Crawler. In scSearchContrib.Crawler.Crawlers.AdvancedDatabaseCrawler class in the CreateField method I have added the following code.

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

in the index configuration I have given the field name name and appended the text "numeric" to it. However I am correctly passing the fieldname by removing the "numeric" part.

when building the index I get a error like this.

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 someone tell me a way to do this using Advanced Database Crawler?

Thanks in Advance

4

1 に答える 1

3

数値フィールドとしてインデックスを作成できませんでしたが、問題の回避策が見つかりました。lucene TermRangeQueryが正しい検索結果を提供するように、埋め込みゼロを使用してインデックスを作成します。すべての価格はパディングされたゼロでインデックス付けされるため、各値には10桁が含まれます。そうすれば、私が得る結果は正確です。

于 2013-02-12T13:30:50.927 に答える