I have an Elastic Search query as:
{
"query": {
"bool": {
"must": [
{
"match": {"title": "accountant"}
},
{
"nested": {
"path": "schools",
"query": {
"bool": {
"must": [
{ "match": { "schools.school_name": "Duke University" }}
]
}}}}
]
}}}
I'm using Elastica library of php and I want to convert this raw query into Elastica. I know I can run raw query from Elastica, but I would prefer using Elastica classes. I have tried this and this. But none of them works. Here is the simplified version of my current code:
$schoolsTermFilter = new \Elastica\Filter\Term(['schools.school_name' => "Duke University"]);
$schoolsBoolFilter = new \Elastica\Filter\Bool();
$schoolsBoolFilter->addMust($schoolsTermFilter);
$nestedFilter = new \Elastica\Filter\Nested();
$nestedFilter->setPath("schools");
$nestedFilter->setFilter($schoolsBoolFilter);
$boolFilter = new \Elastica\Filter\Bool();
$boolFilter->addMust($nestedFilter);
$query->setPostFilter($boolFilter);
However, this returns empty results. The raw query does return results, so I know I should get something. Can anybody help me in this? Thanks