Prashant Patil
Prashant Patil

Reputation: 2563

SOLR: How to boost the result with multiple values with edismax?

I have this type of data in solr.

{
    "MerchantId":"1",
    "Name":"8055 Lace Top, Black / 10",
},
{
    "MerchantId":"1",
    "Name":"8055 Lace Top, Black / 12",
},
{
    "MerchantId":"2",
    "Name":"8055 Lace Top, Black / 10",
},
{
    "MerchantId":"2",
    "Name":"8055 Lace Top, Black / 12",
},
{
    "MerchantId":"3",
    "Name":"8055 Lace Top, Black / 10",
},
{
    "MerchantId":"3",
    "Name":"8055 Lace Top, Black / 12",
},
{
    "MerchantId":"4",
    "Name":"8055 Lace Top, Black / 10",
},
{
    "MerchantId":"4",
    "Name":"8055 Lace Top, Black / 12",
},

Now I want to boost the result by MerchantId so I used the below Query

"params":{
      "q":"Name:black+top",
      "defType":"edismax",
      "_":"1590574183676",
      "bq":"MerchantId:2^10"}
},

This query works as expected. But how to boost 2 or more MerchantId?

Also there is Boost parameter available for eDismax so how to use this parameter and what are the available values for this?

Can we use Boost paramter to boost by MerchantId?

Upvotes: 1

Views: 477

Answers (1)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8658

You can try like below

http://localhost:8983/solr/TestDemo4/select?bq=MerchantId:2^10%20OR%20MerchantId:4^5%20OR%20MerchantId:3^3&defType=edismax&q=MerchantName:black%20top

Here is how the response will look like:

{
  "responseHeader":{
    "zkConnected":true,
    "status":0,
    "QTime":2,
    "params":{
      "q":"MerchantName:black top",
      "defType":"edismax",
      "bq":"MerchantId:2^10 OR MerchantId:4^5 OR MerchantId:3^3"}},
  "response":{"numFound":8,"start":0,"docs":[
      {
        "MerchantId":"2",
        "MerchantName":"8055 Lace Top, Black / 10",
        "id":"a4480fda-4290-465b-9df2-0b1a1ff85dc8",
        "_version_":1667935688585117696},
      {
        "MerchantId":"2",
        "MerchantName":"8055 Lace Top, Black / 12",
        "id":"1c1c76b6-5db7-4175-bec9-48b19b01dfcb",
        "_version_":1667935688585117697},
      {
        "MerchantId":"4",
        "MerchantName":"8055 Lace Top, Black / 10",
        "id":"6c8f9180-0d73-4e1e-9f03-d2d7c4f936d6",
        "_version_":1667935688586166273},
      {
        "MerchantId":"4",
        "MerchantName":"8055 Lace Top, Black / 12",
        "id":"ea076d75-9ce7-4266-a110-ed78ac132e42",
        "_version_":1667935688587214848},
      {
        "MerchantId":"3",
        "MerchantName":"8055 Lace Top, Black / 10",
        "id":"d99345d0-021f-4a29-bb94-57f2f6c00426",
        "_version_":1667935688585117698},
      {
        "MerchantId":"3",
        "MerchantName":"8055 Lace Top, Black / 12",
        "id":"23fe84a4-b918-4836-a01d-677d62e1ff42",
        "_version_":1667935688586166272},
      {
        "MerchantId":"1",
        "MerchantName":"8055 Lace Top, Black / 10",
        "id":"ecb42a06-b989-4cfe-aca4-bf5b5307857a",
        "_version_":1667935688583020544},
      {
        "MerchantId":"1",
        "MerchantName":"8055 Lace Top, Black / 12",
        "id":"3025c18e-a839-49bc-917c-280c29dd8604",
        "_version_":1667935688584069120}]
  }

Upvotes: 2

Related Questions