lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "digy digy" <>
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.


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

        private void button1_Click(object sender, EventArgs e)
            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);


        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
            Query query = queryParser.Parse(TextToSearch);
            RangeFilter dummyFilter = new RangeFilter("Text", "a",
"z", true, true);
            //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.


View raw message