lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "digy digy" <digyd...@gmail.com>
Subject Bug in PhraseQuery,TermQuery ?
Date Mon, 26 Feb 2007 17:18:29 GMT
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