views:

784

answers:

2

I need lucene to search for synonyms as well as the actual keyword. that is if I search for "CI", I want it to search for CI OR "continues integration". at the moment I search for keywords I have the synonyms for and replace them with the "OR-ed" version, but I suspect there should be a better way to do this. my method will not work for complex queries where you have something like "x AND y OR NOT z".

+2  A: 

That's pretty much how I was planning on implementing this functionality. I was planning on building my own version of this but then I ran across this site WordNet.Net which seems to try to address the issue of building the synonyms. There is a wordnet extension to Lucene.Net which rewrites the query, so I'm guessing that is really the standard way of handling this.

Paul Mrozowski
A: 

At least in the Java version of Lucene, you could write yourself a recursive function that digs through the BooleanQuery Query objects that the QueryParser will build; every time it finds a TermQuery, it could replace it with a BooleanQuery that OR's the original term with the new term you want added into the query.

Jay Kominek