3

i am a beginner & developing my very first project with lucene.net i.e. an address search utility, lucene.net 3.0.3

using standard analyzer, query parser, (suppose i have a single field, Stored & Analyzed as well) - sample data : (every row is a document with a single field) (Postcode and street column concatenated)

  • UB6 9AH Greenford Road something
  • UB6 9AP Greenford Road something
  • UB1 3EB Greenford Road something
  • PR8 3JT Greenford Road something
  • HA1 3QD something Greenford Road
  • SM1 1JY something Greenford Road something

Searching

StringBuilder customQuery = new StringBuilder();
customQuery.Append(_searchFieldName + ":\"" + searchTerm + "\"^" + (wordsCount));

// this is for phrase matching

foreach (var word in words.Where(word => !string.IsNullOrEmpty(word)))
    {
        customQuery.Append(" +" + _searchFieldName + ":" + word + "*");
    }

// this is prefix match for each word

Query query = _parser.Parse(customQuery.ToString());

_searcher.Search(query, collector);

all above (searching) working fine

Question

if i search for "Greenford road" , i may want that row that has 'SM1' should come up (means i want to priorities result as per postcode)

i have tested Query-Time-Boost and it works fine

but i may have a long list of priority postcodes sometimes (so i don't want to loop over each postcode and set its priority at query time

I WANT DOCUMENT TIME BOOSTING

but whatever document boost i set (at the time of indexing), it doesn't effect my search results

doc.Add(new Field(SearchFieldName, SearchField, Field.Store.YES, Field.Index.ANALYZED));
if (condition == true)
{
   doc.Boost = 2; // or 5 or 200 etc (nothing works)
}

please HELP

i tried to understand similarity and scoring, but its too much mathematics there...

please help....

GrafikRobot
  • 3,020
  • 1
  • 20
  • 21
sohaib
  • 31
  • 3

1 Answers1

0

I recently had this problem myself and I think it might be due to wildcard queries (It was in my case at least). There is another post here that explains the issue better, and provides a possible solution:

Lucene .net Boost not working when using * wildcard

Perex19
  • 324
  • 1
  • 4
  • 15