Search code examples
solr

How to display the individual score for search results in solr?


I am testing Solr 9.0 with this tutorial:

https://solr.apache.org/guide/solr/latest/getting-started/tutorial-techproducts.html

I used this query:

http://localhost:8983/solr/techproducts/select?q=cat:electronics&fl=name

In the results displayed, it only gives a masScore. How to display each individual score for each result?

"response": {
    "numFound": 12,
    "start": 0,
    "maxScore": 0.5244061,
    "numFoundExact": true,
    "docs": [
      {
        "name": "Samsung SpinPoint P120 SP2514N - hard drive - 250 GB - ATA-133"
      },
      {
        "name": "Maxtor DiamondMax 11 - hard drive - 500 GB - SATA-300"
      },
      {
        "name": "Belkin Mobile Power Cord for iPod w/ Dock"
      },

Solution

  • You can read individual document scores as an additional field in the results via the fl (Field List) parameter.

    The fl parameter limits the information included in a query response to a specified list of fields. The fields must be either stored="true" or docValues="true".

    The field list can be specified as a space-separated or comma-separated list of field names. The string score can be used to indicate that the score of each document for the particular query should be returned as a field. The wildcard character * selects all stored fields in the document.

    http://localhost:8983/solr/techproducts/select?q=cat:electronics&fl=name,score