views:

83

answers:

2

Hi, I need to know when a word or words are inside a field in my index, and have that document swith greater score.

My problem is that if i search for "Sherton Hotel" I get this as greatest results

  1. Petit Hotel
  2. Crzy cow
  3. Simmonss

And i would like this ones to have the greatest results

  1. Maui Sheraton Hotel near the moon
  2. A fantastic hotel that looks like Sheraton

I want that if the words Im searching or similar are inside, in this case, hotelName field they have a greater score.. besides the lenght of the field text.

I assume that for Lucene, "Seraton Hotel" has more similarity with "Crazy Cow" than with "A fantastic hotel that looks like Sheraton".

Thanks in advance!!

A: 

Ok, lets change a little..

I dont know why I cant search with TermQuery. If I do the following I get a nice result

Query query = new FuzzyQuery(new Term("hotelName", hotelNameToSearch), this.getMinSimilarity());

So my Index is working! But when I do this I dont

Term t = new Term("hotelName", hotelNameToSearch);
     Query query = new TermQuery(t);

Im indexing this Documents

Document doc = new Document();
doc.add(new Field("id", hotel.getOID().toString(), Store.YES, Index.NOT_ANALYZED));
doc.add(new Field("hotelName", hotel.getName().toLowerCase(), Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("cityCode", cityCode, Field.Store.YES, Field.Index.ANALYZED));

Any help would be fantastic! Thanks!!

orlandoMG
Done! .. i have problems because in the Index I have UpperCase hotels names.
orlandoMG
You should have edited your Q
synhershko
A: 

TermQuery looks for exact matches, FuzzyQuery does things a little different. Without knowing what hotelNameToSearch and hotel.getName().toLowerCase are I can't really say whats going on, but why aren't you using the built-in queryParser? Just add a tilde (~) with a numeric value to indicate a fuzzy query?

synhershko
Hi Synhershko, in my first approach I did it with queryParser and with greatest result but my boss dont want it that way.No they want it to be done with TermFreqVector ...Thanks for your help!
orlandoMG