api-platform / api-platform/core

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

Open
#5,190 0 comments 0 reactions 0 assignees View on GitHub
Elasticsearch
Dominant language
PHP
Stars
2.6k
Forks
980
Avg merge
2d 2h
Merged PRs (30d)
51

Description

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

```json
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
```json
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
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.