Elasticsearch php relevant results while searching product names and brands

Hi,
I have created a elasticsearch index for an ecommerce database. It contains id,name, brand, brandid, description, category and color columns for each product. I am querying the index using the following parameters.

array:5 [▼
"index" => "product_items" 
"type" => "product_items" 
"from" => 1
"size" => 16 
"body" => array:1 [▼ 
    "query" => array:1 [▼ 
        "bool" => array:1 [▼ 
            "should" => array:1 [▼ 
                "multi_match" => array:3 [▼ 
                    "type" => "most_fields" 
                    "fields" => array:7 [▼ 
                       0 => "name" 
                       1 => "description" 
                       2 => "brand" 
                       3 => "tags" 
                       4 => "collectionname" 
                       5 => "color" 
                       6 => "categories" 
                    ] 
                    "query" => "gucci hand bag" 
                ] 
            ]
         ] 
       ] 
    ]
]

But I am not getting relevant results. I want to show the same brands products at the first if brand name is present in the search query. For example Gucci,I am getting first few products belong to Gucci and then some other brand in between before showing Gucci again. I have read from the documentation that score is not calculated for bool query. I want to check if there is a better way to make the query to get better relevant results. Thanks

I am using the php module for laravel to query the index and elasticsearch 6.0. I hope someone will reply to this.

Here is the mapping of the index.

    "product_items" : {
"mappings" : {
  "product_items" : {
    "properties" : {
      "brand" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      },
      "brand_id" : {
        "type" : "long"
      },
      "categories" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      },
      "category_id" : {
        "type" : "long"
      },
      "collectionname" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      },
      "color" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      },
      "currency" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      },
      "current_price" : {
        "type" : "float"
      },
      "description" : {
        "properties" : {
          "Description" : {
            "type" : "text",
            "fields" : {
              "keyword" : {
                "type" : "keyword",
                "ignore_above" : 256
              }
            }
          }
        }
      },
      "id" : {
        "type" : "long"
      },
      "name" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      },
      "size" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      },
      "tags" : {
        "type" : "text",
        "fields" : {
          "keyword" : {
            "type" : "keyword",
            "ignore_above" : 256
          }
        }
      }
    }
  }
}

}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.