Skip to content

[Elasticsearch] match filters - remove constant_score and allow to sort by _score #5190

Open
@insekticid

Description

@insekticid

Api Plaform shoud have config to disable automatically plugged ApiPlatform\Elasticsearch\Extension\ConstantScoreFilterExtension when using ApiPlatform\Elasticsearch\Filter\MatchFilter;

#[ApiFilter(MatchFilter::class, properties: ['name'])]

Actual Api Platform to ElasticSearch request returns nonsense results

GET /product/_search
{
   "query":{
      "constant_score":{
         "filter":{
            "bool":{
               "must":[
                  {
                     "match":{
                        "name":"PARKSIDE PERFORMANCE Multisvářečka s technologií dvojitého impulzu PMPS 200 A1"
                     }
                  }
               ]
            }
         }
      }
   },
   "sort":[
      {
         "id":{
            "order":"asc"
         }
      }
   ],
   "size":30,
   "from":0
}

Working solution

GET /product/_search
{
   "query":{
            "bool":{
               "must":[
                  {
                     "match":{
                        "name":"PARKSIDE PERFORMANCE Multisvářečka s technologií dvojitého impulzu PMPS 200 A1"
                     }
                  }
               ]
            }
   },
   "sort":[
      {
         "_score":{
            "order":"desc"
         }
      }
   ],
   "size":30,
   "from":0
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions