3

I'm building a search engine with SOLR, and when an user searches for a phrase such as "apple", I get results such as:

Babyfood, apple ... apple, raw

I want "apple, raw" to appear ahead of "babyfood, apple" because the word apple appears in the front. Is there a way to do this with SOLR? To give more score to those results where the search term appears more in the front?

Henley
  • 21,258
  • 32
  • 119
  • 207
  • 1
    Why Solr returns "Babyfood" if you are searching for apple? are you using synonyms? So the question is: how to "de-boost" synonyms?! Could you please post a part of the schema.xml - the type definition of the fieldtype, where "apple" is part of? Something like http://www.ibm.com/developerworks/java/library/j-solr1/ <- Listing 3 – The Bndr Apr 21 '11 at 07:29

1 Answers1

-1

try q=(field:apple*)^2 OR field:apple

where field is the name of the field against which you are searching

Umar
  • 2,819
  • 20
  • 17
  • 1
    Your answer is specific to the term contents (apple) not the position of the term - it does not answer the question. – David Victor May 17 '11 at 12:06
  • well apple is an example term here, and the solution boosts results with apple at the start. However the results will depend on the type of analyzers used for the field. – Umar May 17 '11 at 17:41
  • 2
    The question is regarding how to boost based upon *position* not specific term values. So if we have banana in position 1 does your answer work - no. Please do some research & see if you can improve the answer. – David Victor May 18 '11 at 07:01