Skip to content

Make it work with Doctrine Criteria #3

@kinncj

Description

@kinncj

Once #2 is implemented, figure a way to make it work with Doctrine Common Criteria.
To be honest, I guess this would be a separated project, gotta find a better name though... ElasticDoctrineCriteria sounds gross.

$criteria = Criteria::create()
    ->where(
        Criteria::expr()->orX(
            Criteria::expr()->andX(
                Criteria::expr()->eq("term", "birthday"),
                Criteria::expr()->eq("value", "1987-12-22"),
                Criteria::expr()->eq("boost", 2.0)
            ),
            Criteria::expr()->andX(
                Criteria::expr()->eq("term", "birthday"),
                Criteria::expr()->eq("value", "1988-04-28"),
                Criteria::expr()->eq("boost", 1.0)
            )
        )   
    )
;

$qb = new ElasticQueryBuilder($criteria);

echo $criteria->getQuery();
{
  "query": {
    "bool": {
      "should": [
        {
          "term": {
            "birthday": {
              "value": "1987-12-22",
              "boost": 2.0
            }
          }
        },
        {
          "term": {
            "birthday": {
              "value": "1988-04-28",
              "boost": 1.0
            }
          }
        }
      ]
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions