lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eyal Post" <eyalp...@epocalipse.com>
Subject RE: how do I get the multisearcher to work.
Date Wed, 24 May 2006 20:43:17 GMT
Yes, seems like what I reported for 1.9 RC1:
http://sourceforge.net/forum/message.php?msg_id=3549420 
Is still hapenning in RC2. 

George, I sent you back then a hashSet implementation in c# to use instead
of HashTable (to make it compatible with the java version). This will make
the code cleaner and will solve these kind of problems (dulicate keys) for
good. 
Are you planning to use it?

Eyal

-----Original Message-----
From: Pamela Foxcroft [mailto:pamelafoxcroft@gmail.com] 
Sent: Wednesday, May 24, 2006 19:16 PM
To: lucene-net-dev@incubator.apache.org
Subject: how do I get the multisearcher to work.

I keep on getting this message. We are using 1.9 RC2. Item has already been
added. Key in dictionary: 'text:horse' Key being added: 'text:horse'

Here is my code - this is based on the lucene in action book.


using System;
using System.Collections.Generic;
using System.Text;
using Lucene.Net.Analysis;
using Lucene.Net.Analysis.Standard;
using Lucene.Net.Search;
using Lucene.Net.QueryParsers;
using Lucene.Net.Store;
using Lucene.Net.Index;
using Lucene.Net.Documents;

namespace MultiSearcher
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] animals ={
"aardvark","beaver","coati","dog","elephant","frog","gila
monster","horse","iguana",

"javelina","kangaroo","lemur","moose","nematode","orca","python","quokka","r
at","scorpian","trrantula",
                "uramstyx","vicuna","walrus","Xuphias","yak","zebra"};

            Analyzer analyzer = new WhitespaceAnalyzer();

            Directory aTOmDirectory = new RAMDirectory();
            Directory nTOzDirectory = new RAMDirectory();

            IndexWriter aToMWriter = new IndexWriter(aTOmDirectory,
analyzer, true);
            IndexWriter nToZWriter = new IndexWriter(nTOzDirectory,
analyzer, true);

            for (int i = 0; i < animals.Length; i++)
            {
                Document doc = new Document();
                String animal = animals[i];

                doc.Add(Field.Text("text",animal.ToString()));
            if (i<10)
            {
                aToMWriter.AddDocument(doc);
            }
            else
            {

                nToZWriter.AddDocument(doc);
            }

            }
            aToMWriter.Close();
            nToZWriter.Close();

            IndexSearcher[] searchers = new IndexSearcher[2];
            searchers[0] = new IndexSearcher(aTOmDirectory);
            searchers[1] = new IndexSearcher(nTOzDirectory);

            MultiSearcher searcher = new MultiSearcher(searchers);

            Query query = QueryParser.Parse("horse","text" , new
StandardAnalyzer());
           Console.WriteLine("Query: " + query.ToString());
            Hits hits = searcher.Search(query);  Console.Write("end");
        }
    }
}



thanks



Pam


Mime
View raw message