How to get relevant search results in Solr in particular order of columns.

107 Views Asked by At

I want to group my Solr4.7.2 results in to particular relevant order such that I have 3 columns namely Title, Summary and Content on which I am doing my solr search.

Currently I am using Simple Query Parser by executing this Query.

select?q=2016&fl=title%2Csummary%2Ccontent%2Cscore&wt=json&indent=true

and it is showing me results by searching string "2016"

{
  "responseHeader": {
    "status": 0,
    "QTime": 1,
    "params": {
      "q": "2016",
      "indent": "true",
      "fl": "title,summary,content,score",
      "wt": "json"
    }
  },
  "response": {
    "numFound": 5,
    "start": 0,
    "maxScore": 0.643841,
    "docs": [{
      "title": "Title",
      "summary": "2016 which u",
      "score": 0.643841
    }, {
      "title": "2016 which U The Most",
      "summary": "Summary",
      "score": 0.48288077
    }, {
      "content": [" \n \n  \n  \n  \n  \n  \n \n  def 2016 which U abcd\n \n  "],
      "score": 0.3219205
    }, {
      "content": [" \n \n  \n  \n  \n  \n  \n \n  def 2016 which U abcd\n \n  "],
      "score": 0.3219205
    }, {
      "content": [" \n \n  \n  \n  \n  \n  \n \n  2016 which U The most Important \n \n  "],
      "score": 0.3219205
    }]
  }
}

Now I want to group my results in a way that Exact title match should show first in relevancy order > then the Exact Summary match > then Exact Contenct Exact match. In another group it should show less scorable tile > Summary > content.

For Ex. Expected result should be

{
  "responseHeader": {
    "status": 0,
    "QTime": 1,
    "params": {
      "q": "2016",
      "indent": "true",
      "fl": "title,summary,content,score",
      "wt": "json"
    }
  },
  "response": {
    "numFound": 5,
    "start": 0,
    "maxScore": 0.643841,
    "docs": [{
      "title": "2016 which U The Most",
      "summary": "Summary",
      "score": 0.48288077
    },{
      "title": "Title",
      "summary": "2016 which u",
      "score": 0.643841
    },{
      "content": [" \n \n  \n  \n  \n  \n  \n \n  2016 which U The most Important \n \n  "],
      "score": 0.3219205
    },{
      "content": [" \n \n  \n  \n  \n  \n  \n \n  def 2016 which U abcd\n \n  "],
      "score": 0.3219205
    }, {
      "content": [" \n \n  \n  \n  \n  \n  \n \n  def 2016 which U abcd\n \n  "],
      "score": 0.3219205
    }, ]
  }
}

I tried to use dismax query parser by applying qf=title^2 summary content, but it is not showing me any results.

0

There are 0 best solutions below