Reputation: 27
Is it possible to introduce a custom field in Solr QueryResponse
that would contain a value that is computed based on another response value? For example if I have "score" field in the response, I want my custom field (let it be named "multipliedScore
") to contain value = (score * 10)
;
The value of the custom field needs to be calculated (not static).
Maybe there's a way to take the score value calculated by Solr and multiply it or turn into a string with prefix/postfix (not asking here about turning it into percentages)?
Upvotes: 0
Views: 499
Reputation: 4770
You can achieve this using a DocTransformer
. Just inherit from the class and implement the required logic in the transform
method :
public void transform(SolrDocument doc, int docId) {
String oldValue = doc.getFieldValue(fieldName);
doc.put(newField,getNewValue(oldValue));
}
Upvotes: 1