manticoresoftware / manticoresoftware/manticoresearch-php

Add a method to get total facets count

Open
#67 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting for reply
Dominant language
PHP
Stars
211
Forks
39
Avg merge
1d 20h
Merged PRs (30d)
1

Description

The library doesn't have a method to get total count of facets.

Here is the code example, imagine an index `jobs` with columns `employer_id` and `employer_name`:
```
$client = new \Manticoresearch\Client();
$index = $client->index('jobs');

$query = new \Manticoresearch\Query\BoolQuery();
$query->must(new \Manticoresearch\Query\MatchQuery('amazon', 'employer_name'));

$search = $index->search($query);
$search->limit(0);
$search->offset($offset);
$search->facet('employer_id', null, $per_page);
$result = $search->get();

var_dump($result->getTotal()); // this returns total number of rows, not total number of facets
var_dump($result->getFacets()); // this returns facets
```

So, adding a method similar to this one could solve the issue:

```
$result->getTotalFacets()
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the result object methods getTotal() and getFacets() from the search example, then inspect how facet data is returned by the index search. Add the requested total-facets accessor alongside those methods and verify that it reports the total facet count separately from the total row count.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, search
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.