4
votes

I am using Solr 5.0.0, I have one question in relevance boost:

If I search for laptop table like words, is there any way to boost results search word before the words like by with or without etc.

I used this query:

? defType = dismax 
    & q = foo bar 
    & bq = (*:* -by)^999  

But, this will boost negatively those documents having the word by or with etc. How can i avoid this problem?

For example, if I search for laptop table then by the above query the result DGB Cooling Laptop Table by GDB won't boost.

I just need to give a boost to the search words before certain words like by, with, etc. Is it possible?

1
I don't understand what you need? Is this not what you want in your last question: stackoverflow.com/questions/30621679/solr-rule-based-boost ?alexf
@alexf no. Here the search word before some words like with or by etc. need to be boosted, search word after the words like by,with need not consider.Juhan

1 Answers

0
votes

In your example you want ...laptop table by... results to score higher than laptop table results without by. And you want ...by laptop table... to be omitted entirely.

Let's call them:

  • Q1: ...laptop table by... (let's boost by 2 for the exercise)
  • Q2: ...laptop table... (let's not boost at all)
  • Q3: ...by laptop table... (we want to omit this)

So, your query in the abstract is: (Q1^2 OR Q2) NOT Q3

The dismax parser may be obscuring your goals by doing too much on your behalf. At least for this piece, you should consider using the Standard (Lucene) Query Parser:

`q=("laptop table by"^2 OR "laptop table") NOT "by laptop table"`

If you want to allow for slop (i.e. extra words between the query and 'by' or 'with') and preserve the order of terms as above, you should look into the ComplexPhraseQueryParser (Solr 4.8+) Yonik Seeley has a nice post about this.

Then you could do something like this:

`q=({!complexphrase inOrder=true}"laptop table by"~2^2 OR "laptop table") NOT {!complexphrase inOrder=true}"by laptop table"~2`