You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Yves Gagnon <ga...@videotron.ca> on 2007/07/31 00:58:54 UTC

Index is corrupt ??

I have a web page that is use to extract the information from the index. All
seam to work fine, but when a search engine like google start to parse the
site. For some reason, more files was created in the index directory, and
the index seams to be corrupt. Here is the code that I used.

 

 

ArrayList documents = new ArrayList();

                        

IndexReader reader = IndexReader.Open(indexPath);

Searcher searcher = new IndexSearcher(reader);

Analyzer analyzer = new StandardAnalyzer();

Sort.Sort sort = new Lucene.Net.Search.Sort("rating", false);

QueryParser parser = new QueryParser("content", analyzer);

 

Query query = parser.Parse(texte);

Hits hits = searcher.Search(query, sort);

for (int i = 0; i <= hits.Length() - 1; i += 1)

{

Document doc = hits.Doc(i);

      documents.Add(doc);

}

reader.Close();

return documents;

 

Any idea ?

 

Regards 

 

Yves


RE: Index is corrupt ??

Posted by DIGY <di...@gmail.com>.
Your code seems OK. That bug can be in another location.

DIGY

-----Original Message-----
From: Yves Gagnon [mailto:gagyves@videotron.ca] 
Sent: Tuesday, July 31, 2007 1:59 AM
To: lucene-net-user@incubator.apache.org
Subject: Index is corrupt ??

I have a web page that is use to extract the information from the index. All
seam to work fine, but when a search engine like google start to parse the
site. For some reason, more files was created in the index directory, and
the index seams to be corrupt. Here is the code that I used.

 

 

ArrayList documents = new ArrayList();

                        

IndexReader reader = IndexReader.Open(indexPath);

Searcher searcher = new IndexSearcher(reader);

Analyzer analyzer = new StandardAnalyzer();

Sort.Sort sort = new Lucene.Net.Search.Sort("rating", false);

QueryParser parser = new QueryParser("content", analyzer);

 

Query query = parser.Parse(texte);

Hits hits = searcher.Search(query, sort);

for (int i = 0; i <= hits.Length() - 1; i += 1)

{

Document doc = hits.Doc(i);

      documents.Add(doc);

}

reader.Close();

return documents;

 

Any idea ?

 

Regards 

 

Yves



Re: Index is corrupt ??

Posted by feran <fe...@whereistand.com>.
reader.Flush();
reader.Optimize();

You're adding Documents but not committing them. Flush() and Optimize() are 
for IndexModifier though.. just check up the syntax for IndexReader to make 
sure.

----- Original Message ----- 
From: "Yves Gagnon" <ga...@videotron.ca>
To: <lu...@incubator.apache.org>
Sent: Monday, July 30, 2007 6:58 PM
Subject: Index is corrupt ??


>I have a web page that is use to extract the information from the index. 
>All
> seam to work fine, but when a search engine like google start to parse the
> site. For some reason, more files was created in the index directory, and
> the index seams to be corrupt. Here is the code that I used.
>
>
>
>
>
> ArrayList documents = new ArrayList();
>
>
>
> IndexReader reader = IndexReader.Open(indexPath);
>
> Searcher searcher = new IndexSearcher(reader);
>
> Analyzer analyzer = new StandardAnalyzer();
>
> Sort.Sort sort = new Lucene.Net.Search.Sort("rating", false);
>
> QueryParser parser = new QueryParser("content", analyzer);
>
>
>
> Query query = parser.Parse(texte);
>
> Hits hits = searcher.Search(query, sort);
>
> for (int i = 0; i <= hits.Length() - 1; i += 1)
>
> {
>
> Document doc = hits.Doc(i);
>
>      documents.Add(doc);
>
> }
>
> reader.Close();
>
> return documents;
>
>
>
> Any idea ?
>
>
>
> Regards
>
>
>
> Yves
>
>