How to resove this Error "multi_match query malformed, no start_object after query name" in Symfony Elastic search?

I’ve an error in a symfony project “multi_match query malformed, no start_object after query name” in Symfony ApiPlatform using Elastic search ?

I want to use OR condition in Elasticsearch query using php symfony.

This is the SearcheFilter file (web/src/Bridge/Elastica/Filter/SearchFilter.php):

 case self::STRATEGY_OR:
            $values = array_map('strtolower', $values);
            $multiFieldQuery = new QueryMultiMatch;
            if ('departmentOrNeighboring' === $field) {
                $multiFieldQuery->setFields(['dead.department.name', 'neighboringDepartments.name']);
                $multiFieldQuery->setQuery($values[0]);
                $multiFieldQuery->setMinimumShouldMatch('100%');
            }
            if ('regionOrNeighboring' === $field) {
                $multiFieldQuery->setFields(['dead.region.name', 'neighboringDepartments.regionName']);
                $multiFieldQuery->setQuery($values[0]);
                $multiFieldQuery->setMinimumShouldMatch('100%');
            }
            $boolQuery->addMust($multiFieldQuery);
            break;

and this is the entity annotation fields:

/**
 * Obituary
 *
 * @ORMTable(name="obituary", indexes={@ORMIndex(name="type", columns={"type", "status"}), @ORMIndex(name="status", columns={"status", "publication_date"})})
 *
 * @ApiResource(
 *     attributes={
 *          "normalization_context"={"groups"={"obituary-read"}},
 *          "denormalization_context"={"groups"={"obituary-write"}}
 *     },
 *     collectionOperations={
 *          "get"={
 *              "method"="GET",
 *          },
 *          "post"={
 *              "method"="POST",
 *          }
 *     },
 *     itemOperations={
 *          "get"={
 *              "method"="GET",
 *          },
 *          "put"={
 *              "method"="PUT",
 *          },
 *          "delete"={
 *              "method"="DELETE",
 *          },
 *     }
 * )
 *
 * @ApiFilter(SearchFilter::class, properties={
 *     "dead.firstName": "exact",
 *     "dead.lastName": "exact",
 *     "dead.deathDate": "exact",
 *     "dead.postalCode": "exact",
 *     "publicationDate": "exact",
 *     "type": "exact",
 *     "status": "exact",
 *     "operator": "exact",
 * })
 * @ApiFilter(ObituarySearchFilter::class, properties={
 *     "neighboringDepartments.name": "or",
 *     "neighboringDepartments.parentCode": "exact",
 *     "dead.town.name": "exact",
 *     "dead.department.name": "or",
 *     "dead.region.name": "exact",
 *     "dead.namesDead": "partial",
 *     "dead.institution.id": "exact",
 *     "dead.institution.business.id": "exact",
 *     "departmentOrNeighboring": "or",
 *     "regionOrNeighboring": "or",
 * })
 * @ApiFilter(DateFilter::class, properties={"dead.deathDate", "publicationDate", "createdDate"})
 * @ApiFilter(OrderFilter::class, properties={"dead.deathDate", "dead.firstName", "dead.lastName", "dead.town.name", "publicationDate", "createdDate"})
 *
 * @ORMEntity(repositoryClass="AppRepositoryObituaryRepository")
 */

So I don’t know where does the problem come from.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *