lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luke Shannon" <lshan...@futurebrand.com>
Subject Re: Problems...
Date Tue, 04 Jan 2005 16:02:50 GMT
I had a similar situation with the same problem.

I found the previous system was creating all the object (including the
Searcher) and than updating the Index.

The result was the Searcher was not able to find any of the data just added
to the Index.

The solution for me was to move the creation of the Searcher to after the
Index had been updated and the Reader and Writer objects had been closed.
Also ensure the Searcher uses the same Analyzer as the IndexWriter used to
create the Index.

This is a good tool for checking what is in your index. It may help with the
trouble shooting:

http://www.getopt.org/luke/

Luke

----- Original Message ----- 
From: "Ross Rankin" <ross@commercescience.com>
To: <lucene-user@jakarta.apache.org>
Sent: Tuesday, January 04, 2005 10:53 AM
Subject: Problems...


> (Bear with me; I have inherited this system from another developer who is
no
> longer with the company.  So I am not familiar with Lucene at all.  I just
> have got the task of "Fixing the search".)
>
>
>
> I have servlet that runs every 10 minutes and indexes and I can see files
> being created in the index path on that interval (fdt,fdx,fnm,frq, etc.)
> however the search function is no longer working.  I'm not getting
anything
> in the log that I can point to that says what is not working, the search
or
> the index.  But since the index files seem to change size/date stamp as
they
> have in the past, I'm leaning towards the search function.
>
>
>
> I'm not sure where or how to troubleshoot.  Can I examine the indexes with
> anything to see what is there and that it's meaningful.  Is there
something
> simple I can do to track down what doesn't work in the process?  Thanks.
>
>
>
> Ross
>
>
>
> Here's the search function:
>
>     public Hits search(String searchString, String resellerId) {
>
>         int currentOffset = 0;
>
>         try {
>
>             currentOffset = Integer.parseInt(paramOffset);
>
>         } catch (NumberFormatException e) {}
>
>
>
>         System.out.println("\n\t\tSearch for " + searchString + " off = "
+
> currentOffset);
>
>         if (currentOffset > 0) {
>
>             // if the user only requested the next n items from the search
> returns
>
>             return hits;
>
>         }
>
>
>
>         // performs a new search
>
>         try {
>
>             hits = null;
>
>             try {
>
>                 searcher.close();
>
>             } catch (Exception e){}
>
>
>
>             searcher = new IndexSearcher(pathToIndex);
>
>             Analyzer analyzer = new StandardAnalyzer();
>
>
>
>             String searchQuery = LuceneConstants.FIELD_RESELLER_IDS + ":"
>
>                     + resellerId
>
>                     + " AND "
>
>                     + LuceneConstants.FIELD_FULL_DESCRIPTION + ":" +
> searchString;
>
>
>
>
>
>             Query query = null;
>
>             try {
>
>                 query = QueryParser.parse(searchQuery,
>
>                             LuceneConstants.FIELD_FULL_DESCRIPTION,
> analyzer);
>
>             } catch (ParseException e) {
>
>                 // if an excepption occures parsing the search string
> entered by the user
>
>                 // escapes all the special lucene chars and try to make
the
> query again.
>
>                 searchQuery = LuceneConstants.FIELD_RESELLER_IDS + ":"
>
>                     + resellerId + " AND "
>
>                     + LuceneConstants.FIELD_FULL_DESCRIPTION + ":"
>
>                     + escape(searchString);
>
>                 query = QueryParser.parse(searchQuery,
>
>                             LuceneConstants.FIELD_FULL_DESCRIPTION,
> analyzer);
>
>             }
>
>             System.out.println("Searching for: " +
> query.toString(LuceneConstants.FIELD_FULL_DESCRIPTION));
>
>
>
>             hits = searcher.search(query);
>
>             System.out.println(hits.length() + " total matching
documents");
>
>             //searcher.close();
>
>
>
>         } catch (Exception e) {
>
>             e.printStackTrace();
>
>         }
>
>
>
>         return hits;
>
>


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


Mime
View raw message