简体   繁体   中英

How to implement constant scoring in Solr.Net?

I have a SOLR query which I want to assign a constant score to. How do I do that using SOLR.Net?

Example of query:

(x_type_s:("Person") AND _query_:("{!type=parent which=x_type_s:Person}((path_s:Facets.Emails AND email_s:testaccount@sgmail.com)^=1)"))

I know SOLR.Net allows Local params to set parent queries but I found nothing to implement constant scoring.

Constant Score with ^=

There is a concept of Constant Score queries in Solr which will only look for a match and do not impact the document score. In your query, you have already used the constant score clause but for nested query. How about if you enclosed the whole query inside constant query clause.

(x_type_s:("Person") AND _query_:("{!type=parent which=x_type_s:Person}((path_s:Facets.Emails AND email_s:testaccount@sgmail.com)^=1)"))^=1

From the solr documentation

Constant score queries are created with ^=, which sets the entire clause to the specified score for any documents matching that clause. This is desirable when you only care about matches for a particular clause and don't want other relevancy factors such as term frequency (the number of times the term appears in the field) or inverse document frequency (a measure across the whole index for how rare a term is in a field).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM