lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeroen Lauwers <Jeroen.Lauw...@CTLO.NET>
Subject RE: Lucene: Inconsistent results
Date Fri, 12 May 2017 21:38:07 GMT

I was  already using one the latest releases, but to make sure, I updated to the latest Nuget
package. (4.8.0-beta00001)

I'm sorry to say that the issue remains.


-----Original Message-----
From: Shad Storhaug [] 
Sent: vrijdag 12 mei 2017 23:23
To: Jeroen Lauwers <Jeroen.Lauwers@CTLO.NET>
Subject: RE: Lucene: Inconsistent results


You didn't mention what version you are using. If you are not using the latest version (4.8.0-beta00001)
from NuGet, could you please update to let us know if this is still an issue? 

Shad Storhaug (NightOwl888)

-----Original Message-----
From: [] On Behalf Of Itamar
Sent: Friday, May 12, 2017 7:49 PM
Subject: Fwd: Lucene: Inconsistent results

Thanks Jeroen.

I have seen a very similar bug report just last week and I can't seem to find it now. It probably
has something to do with the numeric type used under the hood. With your permission, I'm forwarding
this to the dev@ mailing list and hope to be able to pick this up and investigate in a few

Shad, please let me know if this is already on your radar for fixing

Thanks again for the bug report.


Itamar Syn-Hershko
Freelance Developer & Consultant
Elasticsearch Partner
Microsoft MVP | Lucene.NET PMC | @synhershko <>

---------- Forwarded message ----------
From: Jeroen Lauwers <>
Date: Fri, May 12, 2017 at 2:20 PM
Subject: Lucene: Inconsistent results
To: "" <>

Dear Itamar,

I’m having problems sending and receiving mails to the lucenenet-mailing list, so I’m
contacting you directly.

My config:

-          Windows 10 Enterprise x64

-          Intel i5-5287U

-          Visual Studio 2015 Update 3

Steps to reproduce the error:

1.       Create a new Visual C#/Windows/Windows Forms Application

2.       Add 2 buttons to Form

3.       Copy code (below) into Form1

4.       Change the namespace appropriately

5.       Link click events of buttons to the events in the code

6.       Check Project properties are set as follows:

a.       Build/Platform Target: Any CPU

b.      Prefer 32-bit: checked

7.       Run the project

8.       Create the index (button 1)

9.       Read from the index (button 2)

a.       This should be successful

10.   To make it fail:

11.   Stop project

12.   Change project properties:

a.       Build/Platform Target: x64

b.      Prefer 32-bit: UN-checked (grayed out)

13.   Run the project

14.   DO NOT RE-CREATE THE INDEX (button 1)

15.   Read from the index (button 2)

a.       An exception is thrown: “Index was outside the bounds of the
array.” on “Facets facets = new FastTaxonomyFacetCounts(taxoReader,
facetConfig, c);”

My conclusion:

Reading the index is only successful when the project build settings are the same for creating
and reading.

In the taxo-index, the .si files contain info on the system … so this is intentionally ???

Thanks at a lot for your time and effort,

Jeroen Lauwers


using System;

using System.Windows.Forms;

using Lucene.Net.Index;

using Lucene.Net.Documents;

using Lucene.Net.Search;

using Lucene.Net.Facet;

using Lucene.Net.Facet.Taxonomy;

namespace Lucene_32_64


    public partial class Form1 : Form


        private string[] _alfabeth = new string[] { "A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };

        private int _times = 500;

        private string _indexDir = System.IO.Path.Combine(@"c:\temp",

        private string _taxoDir = System.IO.Path.Combine(@"c:\temp", "taxo"

        public Form1()




        private void button1_Click(object sender, EventArgs e)


            FacetsConfig facetConfig = GetFacetConfig();

            IndexWriterConfig iwCfg = new IndexWriterConfig(Lucene.Net.Util.
LuceneVersion.LUCENE_48, new Lucene.Net.Analysis.Standard.StandardAnalyzer

            iwCfg.OpenMode = OpenMode.CREATE;

            iwCfg.RAMBufferSizeMB = 250;

            Lucene.Net.Store.SimpleFSDirectory nFsd = new Lucene.Net.Store.
SimpleFSDirectory(new System.IO.DirectoryInfo(_indexDir));

            IndexWriter indexWriter  = new IndexWriter(nFsd, iwCfg);

taxoWriter = new Lucene.Net.Facet.Taxonomy.Directory.DirectoryTaxonomyWriter
(Lucene.Net.Store.FSDirectory.Open(new System.IO.DirectoryInfo(_taxoDir)),

            foreach (string letter in _alfabeth)


                for (int i = 0; i < _times; i++)


                    Document doc = new Document();

                    doc.Add(new StringField("Field1", letter, Field.Store .NO));

                    doc.Add(new FacetField("facetField1", letter));

                    doc.Add(new StringField("Field2", i.ToString(), Field.

                    doc.Add(new FacetField("facetField2", i.ToString()));





            Lucene.Net.Util.IOUtils.Close(indexWriter, taxoWriter, nFsd);


        private void button2_Click(object sender, EventArgs e)


            FacetsConfig facetConfig = GetFacetConfig();

            Lucene.Net.Store.SimpleFSDirectory nFsd = new Lucene.Net.Store.
SimpleFSDirectory(new System.IO.DirectoryInfo(_indexDir));

            IndexReader indexReader = DirectoryReader.Open(nFsd);

            IndexSearcher searcher = new IndexSearcher(indexReader);

taxoReader = new Lucene.Net.Facet.Taxonomy.Directory.DirectoryTaxonomyReader
(Lucene.Net.Store.FSDirectory.Open(new System.IO.DirectoryInfo(_taxoDir)));



                foreach (string letter in _alfabeth)


                    FacetsCollector c = new FacetsCollector();

                    searcher.Search(new Lucene.Net.Search.TermQuery(new Term ("Field1", letter)),

                    Facets facets = new FastTaxonomyFacetCounts(taxoReader,
facetConfig, c);

                    FacetResult result = facets.GetTopChildren(int.MaxValue,

                    if (_times != (int)result.LabelValues[0].Value)


                        MessageBox.Show("Fail 1");



                    FacetResult result2 = facets.GetTopChildren(int.MaxValue,

                    for (int i = 0; i < _times; i++)


                        if (i != System.Convert.ToInt32(result2


                            MessageBox.Show("Fail 2");









                Lucene.Net.Util.IOUtils.Close(indexReader, taxoReader, nFsd);



        private FacetsConfig GetFacetConfig()


            FacetsConfig facetConfig = new FacetsConfig();

            FacetsConfig config = new FacetsConfig();

            config.SetRequireDimCount("facetField1", true);

            config.SetRequireDimCount("facetField2", true);

            return facetConfig;



View raw message