lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "George Aroush" <geo...@aroush.net>
Subject RE: Bug in PhraseQuery,TermQuery ?
Date Thu, 01 Mar 2007 01:27:24 GMT
Hi,

Thanks for reporting this as well as for providing a sample code to show the
problem.

This is a defect and I think I know where it may be.  What version of
Lucene.Net are you using?

Regards,

-- George Aroush


-----Original Message-----
From: digy digy [mailto:digydigy@gmail.com] 
Sent: Monday, February 26, 2007 12:18 PM
To: lucene-net-dev@incubator.apache.org
Subject: Bug in PhraseQuery,TermQuery ?

Hi all,

I have an application searching from multiple indices using "MultiSearcher".
When i type the search criterion twice(like "search search"), i get an
exception in TermQuery.cs.
 TermQuery.cs -> ExtractTerms
 "Item has already been added. Key in dictionary: 'Text:search'  Key being
added: 'Text:search' "

I prepared a sample code to regenerate the error condition.

//Sample:-------------------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Lucene.Net.Search;
using Lucene.Net.Documents;
using Lucene.Net.Index;
using Lucene.Net.QueryParsers;
using Lucene.Net.Highlight;

namespace LuceneTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            CreateIndex("Index1");
            Search("Index1","search search");
        }

        void CreateIndex(string Path)
        {
            IndexWriter wr = new IndexWriter(Path, new
Lucene.Net.Analysis.Standard.StandardAnalyzer(), true);

            Document doc = new Document();
            Field f = new Field("Text", "This is a dummy text",
Field.Store.YES, Field.Index.TOKENIZED);
            doc.Add(f);
            wr.AddDocument(doc);

            wr.Close();
        }

        private void Search(string Path,string TextToSearch)
        {
            IndexSearcher searcher1     = new IndexSearcher(Path);
            MultiSearcher multiSearcher = new MultiSearcher(new Searchable[]
{ searcher1 });

            QueryParser queryParser = new QueryParser("Text", new
Lucene.Net.Analysis.Standard.StandardAnalyzer());
            queryParser.SetDefaultOperator(QueryParser.Operator.AND);
            Query query = queryParser.Parse(TextToSearch);
            RangeFilter dummyFilter = new RangeFilter("Text", "a", "z",
true, true);
            //OR
            //QueryFilter dummyFilter = new QueryFilter(query);

            TopDocs td = multiSearcher.Search(query,dummyFilter,100);
            MessageBox.Show(td.totalHits.ToString() + " result(s) found.");
        }

    }
}
//--------------------------------------------


Same bug exists also in PhraseQuery(ExtractTerms) when using  FuzzySearch.

Thanks.
----
DIGY


Mime
View raw message