Hi Harini, Harini Raghavan wrote: > I am trying to create a lucene query to search for companies based on > areacode. The phone no. is stored in the lucene index in the form of > '415-567-2323'. I need to create a query like +areaCode:"415-". But the > QueryParser is stripping off the hyphen(-). > > Here is the code to create the query: > Query query = QueryParser.parse("415-", "phone", analyzer); > > I tried by escaping the hyphen and even that did not work. > Query query = QueryParser.parse ("415\\-", "phone", analyzer); > > Can anyone please suggest a way to do this?
I think what you want is something like: Query query = new PrefixQuery(new Term("phone","415-*")); This assumes that "415-576-2323" is stored as a single term in the index - searching with "415-" as a term will not match against full phone numbers, unless you do some form of expansion (like the PrefixQuery example I gave above). Steve -- Steve Rowe Center for Natural Language Processing http://www.cnlp.org/tech/lucene.asp --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]