lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Itamar Syn-Hershko <ita...@code972.com>
Subject Fwd: Lucene: Inconsistent results
Date Fri, 12 May 2017 12:48:34 GMT
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
days.

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
http://code972.com | @synhershko <https://twitter.com/synhershko>
http://BigDataBoutique.co.il/

---------- Forwarded message ----------
From: Jeroen Lauwers <Jeroen.Lauwers@ctlo.net>
Date: Fri, May 12, 2017 at 2:20 PM
Subject: Lucene: Inconsistent results
To: "itamar@code972.com" <itamar@code972.com>


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



Code:

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",
"index");

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



        public Form1()

        {

            InitializeComponent();

        }



        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
(Lucene.Net.Util.LuceneVersion.LUCENE_48));

            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);



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



            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.
Store.NO));

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



                    indexWriter.AddDocument(facetConfig.Build(taxoWriter,
doc));

                }

            }

            indexWriter.Commit();



            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);



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



            try

            {

                foreach (string letter in _alfabeth)

                {

                    FacetsCollector c = new FacetsCollector();

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



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



                    FacetResult result = facets.GetTopChildren(int.MaxValue,
"facetField1");

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

                    {

                        MessageBox.Show("Fail 1");

                        return;

                    }



                    FacetResult result2 = facets.GetTopChildren(int.MaxValue,
"facetField2");

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

                    {

                        if (i != System.Convert.ToInt32(result2
.LabelValues[i].Label))

                        {

                            MessageBox.Show("Fail 2");

                            return;

                        }

                    }

                }

                MessageBox.Show("Success");

            }

            finally

            {

                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;

        }

    }

}

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message