I have created a small dataset (currently only 8 items) in an Elastic Search index.
The entries are structured as follows
{
"value_a": "Foo",
"value_b": "Bar",
"value_c": "Baz"
}
In Elastic Search this then looks as follows (taken from querying my Elastic Search endpoint directly) :
{
"_index": "foo_bar_bazindex",
"_type": "foo_bar_baz",
"_id": "4",
"_score": 1,
"_source": {
"value_a": "Foo",
"value_b": "Bar",
"value_c": "Baz"
}
}
The combinations of value a, b and c are unique.
I want to find the values of "value_c" by performing a bool filtered search with the values a and b.
In my code I have been trying this as follows:
$filter = new \Elastica\Filter\Bool();
$query = new \Elastica\Query();
$aFilter = new \Elastica\Filter\Term(['value_a' => "Foo"]);
$bFilter = new \Elastica\Filter\Term(['value_b' => "Bar"]);
$filter->addMust($aFilter);
$filter->addMust($bFilter);
$query->setFilter($filter);
$results = $this->bookingPeriodIndex->search($query)->getResults();
var_dump($results);
However this returns no results (the var dump outputs an empty array) - also manually trying this query by posting this query directly to the server:
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"value_a": "Foo"
}
},
{
"term": {
"value_b": "Bar"
}
}
]
}
}
}
}
}
This also yields no results - I would however expect it to return one result as I have the following entry:
{
"value_a": "Foo",
"value_b": "Bar",
"value_c": "Baz"
}
Am I missing something? Could it be due to the small dataset? We use the same Bool Filter Elastica queries elsewhere in our codebase and these work as expected, however I cannot seem to get any data to return from this index.
Any help would be appreciated.