You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Daniel Cortes <dc...@fib.upc.edu> on 2005/07/25 13:39:17 UTC

Searching in Multiple Index

I have a problem searching in 6 index lucene at same time, i founded the 
class MultiSearcher but I think I don't use corretly because it show me 
this error:

java.io.IOException: Bad file descriptor
       at java.io.RandomAccessFile.seek(Native Method)
       at 
org.apache.lucene.store.FSInputStream.readInternal(FSDirectory.java:415)
       at 
org.apache.lucene.store.InputStream.readBytes(InputStream.java:61)
       at 
org.apache.lucene.index.CompoundFileReader$CSInputStream.readInternal(CompoundFileReader.java:220) 

       at org.apache.lucene.store.InputStream.refill(InputStream.java:158)
       at org.apache.lucene.store.InputStream.readByte(InputStream.java:43)
       at org.apache.lucene.store.InputStream.readVInt(InputStream.java:83)
       at 
org.apache.lucene.index.SegmentTermEnum.readTerm(SegmentTermEnum.java:142)
       at 
org.apache.lucene.index.SegmentTermEnum.next(SegmentTermEnum.java:115)
       at 
org.apache.lucene.index.TermInfosReader.scanEnum(TermInfosReader.java:143)
       at 
org.apache.lucene.index.TermInfosReader.get(TermInfosReader.java:137)
       at 
org.apache.lucene.index.SegmentReader.docFreq(SegmentReader.java:253)
       at 
org.apache.lucene.search.IndexSearcher.docFreq(IndexSearcher.java:69)
       at org.apache.lucene.search.Similarity.idf(Similarity.java:255)
       at 
org.apache.lucene.search.TermQuery$TermWeight.sumOfSquaredWeights(TermQuery.java:47) 

       at 
org.apache.lucene.search.BooleanQuery$BooleanWeight.sumOfSquaredWeights(BooleanQuery.java:110) 

       at org.apache.lucene.search.Query.weight(Query.java:86)
       at 
org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:85)
       at 
org.apache.lucene.search.MultiSearcher.search(MultiSearcher.java:116)
       at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:64)
       at org.apache.lucene.search.Hits.<init>(Hits.java:43)
       at org.apache.lucene.search.Searcher.search(Searcher.java:33)


I have 6 index created by IndexWriter (1 index has something indexed, 
but the others are empty (only the segment file)).
If I try to open my indexs with LUKE the index that has something, don't 
give me problems and I can see their fields, but the other empties 
indexsever reply my:                     Invalid path, or not a Lucene 
index.

My code to use the search is this:

private String[] fields= new String[] {"TITLE","CONTENTS","DESCRIPTION"};
//This line I don't know what it do, but I don't think that is the problem
private int[] required= 
{MultiFieldQueryParser.NORMAL_FIELD,MultiFieldQueryParser.NORMAL_FIELD,MultiFieldQueryParser.NORMAL_FIELD}; 

IndexSearcher[] searchers;

//I  initialize  searchers and do this;
           MultiSearcher searcher = new MultiSearcher(searchers);
           Query searcht = 
MultiFieldQueryParser.parse("something",fields,required,getTheInstanceOfMyAnalizer()); 

           Hits resul=searcher.search(searcht);

Perhaps don't  I create well the indexs?

I do this for every File indexDir
           IndexWriter writer;
           File dir = new File();
            if (dir.isDirectory()) {
               writer = new IndexWriter(dir, myAnalyzer, false);
               writer.setUseCompoundFile(true);
            } else {
               dir.mkdirs();
                writer = new IndexWriter(dir, myAnalyzer, true);
               writer.setUseCompoundFile(true);
            }
               writer.optimize();
               writer.close();

Is it correct,true?

I'm sure that my problem is in MultiSearcher caller, but I can't see 
where's my mistake (and not in my english :D) thks in advance.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Searching in Multiple Index

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
What is the point of having empty indexes?   I don't know for sure  
without trying it myself, but perhaps  you need to write at least one  
document to the index for it to be a valid index?   Don't continue  
until Luke is happy with your index.

     Erik


On Jul 25, 2005, at 7:39 AM, Daniel Cortes wrote:

> I have a problem searching in 6 index lucene at same time, i  
> founded the class MultiSearcher but I think I don't use corretly  
> because it show me this error:
>
> java.io.IOException: Bad file descriptor
>       at java.io.RandomAccessFile.seek(Native Method)
>       at org.apache.lucene.store.FSInputStream.readInternal 
> (FSDirectory.java:415)
>       at org.apache.lucene.store.InputStream.readBytes 
> (InputStream.java:61)
>       at org.apache.lucene.index.CompoundFileReader 
> $CSInputStream.readInternal(CompoundFileReader.java:220)
>       at org.apache.lucene.store.InputStream.refill 
> (InputStream.java:158)
>       at org.apache.lucene.store.InputStream.readByte 
> (InputStream.java:43)
>       at org.apache.lucene.store.InputStream.readVInt 
> (InputStream.java:83)
>       at org.apache.lucene.index.SegmentTermEnum.readTerm 
> (SegmentTermEnum.java:142)
>       at org.apache.lucene.index.SegmentTermEnum.next 
> (SegmentTermEnum.java:115)
>       at org.apache.lucene.index.TermInfosReader.scanEnum 
> (TermInfosReader.java:143)
>       at org.apache.lucene.index.TermInfosReader.get 
> (TermInfosReader.java:137)
>       at org.apache.lucene.index.SegmentReader.docFreq 
> (SegmentReader.java:253)
>       at org.apache.lucene.search.IndexSearcher.docFreq 
> (IndexSearcher.java:69)
>       at org.apache.lucene.search.Similarity.idf(Similarity.java:255)
>       at org.apache.lucene.search.TermQuery 
> $TermWeight.sumOfSquaredWeights(TermQuery.java:47)
>       at org.apache.lucene.search.BooleanQuery 
> $BooleanWeight.sumOfSquaredWeights(BooleanQuery.java:110)
>       at org.apache.lucene.search.Query.weight(Query.java:86)
>       at org.apache.lucene.search.IndexSearcher.search 
> (IndexSearcher.java:85)
>       at org.apache.lucene.search.MultiSearcher.search 
> (MultiSearcher.java:116)
>       at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:64)
>       at org.apache.lucene.search.Hits.<init>(Hits.java:43)
>       at org.apache.lucene.search.Searcher.search(Searcher.java:33)
>
>
> I have 6 index created by IndexWriter (1 index has something  
> indexed, but the others are empty (only the segment file)).
> If I try to open my indexs with LUKE the index that has something,  
> don't give me problems and I can see their fields, but the other  
> empties indexsever reply my:                     Invalid path, or  
> not a Lucene index.
>
> My code to use the search is this:
>
> private String[] fields= new String[]  
> {"TITLE","CONTENTS","DESCRIPTION"};
> //This line I don't know what it do, but I don't think that is the  
> problem
> private int[] required=  
> {MultiFieldQueryParser.NORMAL_FIELD,MultiFieldQueryParser.NORMAL_FIELD 
> ,MultiFieldQueryParser.NORMAL_FIELD};
> IndexSearcher[] searchers;
>
> //I  initialize  searchers and do this;
>           MultiSearcher searcher = new MultiSearcher(searchers);
>           Query searcht = MultiFieldQueryParser.parse 
> ("something",fields,required,getTheInstanceOfMyAnalizer());
>           Hits resul=searcher.search(searcht);
>
> Perhaps don't  I create well the indexs?
>
> I do this for every File indexDir
>           IndexWriter writer;
>           File dir = new File();
>            if (dir.isDirectory()) {
>               writer = new IndexWriter(dir, myAnalyzer, false);
>               writer.setUseCompoundFile(true);
>            } else {
>               dir.mkdirs();
>                writer = new IndexWriter(dir, myAnalyzer, true);
>               writer.setUseCompoundFile(true);
>            }
>               writer.optimize();
>               writer.close();
>
> Is it correct,true?
>
> I'm sure that my problem is in MultiSearcher caller, but I can't  
> see where's my mistake (and not in my english :D) thks in advance.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org