lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From walki2 <>
Subject Discard search results based on a doc field comparison
Date Wed, 13 May 2009 09:38:50 GMT


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
		// 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
		// 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

View this message in context:
Sent from the Lucene - Java Developer mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message