0

I am using Solr 5.3.0 to make a news searching system. Assume I have these following fields of news:{

  • Title
  • Content
  • Date
  • NewsType

}

I am searching both of the company name and the manager name in this searching system. Lets say "Stark Industries" as the company name and "Tony Stark" as the manager name. I want to sort the result by date (this is easy to do), relevancy, and following rules:

A:

  1. News that the terms exist in both 'Title' field and 'Content' field.

  2. News that the terms exist only in the 'Title' field.

  3. News that the terms exist only in the 'Content' field.

B:

  1. News that both Company Name (Stark Industries)and Manager Name (Tony Stark) exist.

  2. News that only Company Name exist.

  3. News that only Manager Name exist.

The order should be 1>2>3 (which mean 1 should on the top of 2). And A and B should be two different ways to score the news. And the final score may equal to A*B.

I give "Title" field more weight than "Content" field using this code defType = edismax & qf=notice_title^200+notice_content. So I make the "Title" field more important than the "Content" field.

But in this way, I cannot make sure that A1 > A2 > A3. It only increases the score of the 'Title' field. Same with the rule B, I only can use qf to increase the weight of the Comany Name.

If there is a way to increase the weight of (Title && Content):(CompanyName && ManagerName) should help. (I try to mean both terms exist in both fields.) But this syntax doesn't work in qf.

Any helps will be appreciated.

Summer Li
  • 1
  • 2

2 Answers2

0

You can set omitTermFreqAndPosition for your field, which will ignore the frequency of the terms in the field, making the score independent on the number of times the term appear in the document.

That being said, it's usually better to be a bit more fluent in relevancy calculations than having hard rules like this, but you can implement them by sorting by a function query. Using the function query, you can issue the queries by themselves and then sort by each query.

MatsLindh
  • 49,529
  • 4
  • 53
  • 84
0

Make use of Solr boost queries to achieve that.

Saurabh Chaturvedi
  • 2,028
  • 2
  • 18
  • 39