Hi,

I have a website in 3 languages. The language management is done with Apache
Struts MessageResources, so all the text is stored within .properties files.
These .properties files are indexed and for each doc there is a field called
language which is set to either en,fr or nl. At the moment if a user starts
a search, results for all 3 languages are returned.

Based on the session I can retrieve the users current language. I would like
to discard all search results (docs) which do not match the user's language.

For now, my code looks like this:


        public void search(String keywords) {
                
                // parse the keywords string 
                Query query = null;
                try {
                        query = searcher.getParser().parse(keywords);
                } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                // allows to display the best results first
                collector = new TopDocCollector(hitsPerPage);
                // Perform the actual search
                try {
                        searcher.getSearcher().search(query, collector);
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                // Save the search results to hits[]
                hits = collector.topDocs().scoreDocs;
                // Get the number of documents found
                numTotalHits = collector.getTotalHits();
        }


searcher.getSearcher() returns an instance of my own Searcher class which
contains a StandardAnalyzer, a MultiFieldQueryParser, an IndexReader and an
IndexSearcher.

Thx,
walki
-- 
View this message in context: 
http://www.nabble.com/Discard-search-results-based-on-a-doc-field-comparison-tp23518565p23518565.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to