D
D
Dmitry Sergeev2012-09-21 18:21:30
Sphinx
Dmitry Sergeev, 2012-09-21 18:21:30

When searching across multiple indexes, is it possible to find out the total_found for each index?

There are three indexes a, b, c which are indexes of different tables in the database. When searching across all indices, the result is general information on the query. I would like to get information for each index, how many entries it has.

You can of course make three requests, but maybe there is a more optimal method?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Sergeev, 2012-09-21
@JetMaster

It seems that I found the optimal solution, it may be useful to someone.
Enter the index_id attribute in the indexes and fill it in as follows

source a:db
{
    sql_query = SELECT *,  "a" as index_id FROM table_a 
    sql_query_info  = SELECT * FROM table_a WHERE id=$id
    sql_attr_string = index_id
}

For the rest of the indexes, we do the same, only we change the letter in the query
. On the client, we make two queries: the first gets the number of occurrences of the query in each index, the second gets the results.
$sphinx->SetGroupBy("index_id", SPH_GROUPBY_ATTR, "index_id ASC");
$query_info = $sphinx->Query($query); // 1ый запрос, получаем информацию о запросе

var_dump($query_info);

$sphinx->ResetGroupBy();
$result = $sphinx->Query($query); // 1ый запрос, обычный

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question