P.S. This would also be better posted on the user list, not the dev list. (Forgot which list I was on)
Best Erick On Wed, May 13, 2009 at 8:53 AM, Erick Erickson <erickerick...@gmail.com>wrote: > I don't quite understand what your code snipped is about, but to > your larger problem, why not just index the language along with the > doc and add a "language:<whatever>" to your query? > > But using StandardAnalyzer probably isn't as useful as it could be, > since accented characters wouldn't be found when searching for > non-accented characters and vice-versa which is often not the most > useful to the user. You might want to think about IsoLatin1Filter etc. > > Best > Erick > > > On Wed, May 13, 2009 at 5:38 AM, walki2 <kim.wali...@gmail.com> wrote: > >> >> 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: java-dev-unsubscr...@lucene.apache.org >> For additional commands, e-mail: java-dev-h...@lucene.apache.org >> >> >