Elasticsearch add numeric field to which represent document relevance?


I am using Elasticsearch and NEST to query posts similar to Stackoverflow's.

public class Post
   public string Id { get; set; }       
   public string Title { get; set; }
   public string Body { get; set; }   
   public IEnumerable<string> Tags { get; set; }     
   public int Score { get; set; }        
   public int Views{ get; set; }

I want Elasticsearch to look at Score and Views when calculating hits relevance, so that high Score or Views value move results higher in the results.

(Christoph) #2

Hi jlp1

this looks like a good use case for the Function Score Query, especially the field_value_factor option. You probably need to tweak the weights and modifier a bit depending on the numeric ranges your score and views fields take.


Thanks, I found an example: https://www.elastic.co/guide/en/elasticsearch/guide/current/boosting-by-popularity.html

(system) #4