多值字段的多面搜索

问题描述 投票:0回答:1

我有一个表,其中用逗号表示多个值的字段:

+------+---------------+
| id   | education_ids |
+------+---------------+
|    3 | 7,5           |
|    4 | 7,3           |
|    5 | 1,5           |
|    8 | 3             |
|    9 | 5,7           |
|   11 | 9             |
...
+------+---------------+

当我尝试使用多面搜索时:

select id,education_ids from jobResume facet education_ids;

我正在收到此回复:

+---------------+----------+
| education_ids | count(*) |
+---------------+----------+
| 7,5           |     3558 |
| 7,3           |     3655 |
| 1,5           |     3686 |
| 3             |    31909 |
| 5,7           |     3490 |
| 9             |    31743 |
| 9,6           |     3535 |
| 8,2           |     3547 |
| 6,2,7         |      291 |
| 7,8,1         |      291 |
| 1,2           |     3637 |
| 7             |    31986 |
| 5,9,7         |      408 |
| 1,1,5         |      365 |
| 5             |    31768 |
| 3,8,3,7       |       32 |
| 3,7,6         |      431 |
| 2             |    31617 |
| 5,5           |     3614 |
| 9,9,2,2       |        6 |
+---------------+----------+

但是那不是我想要看到的。我想每个值都有自己的计数,例如在这里:

+---------------+----------+
| education_ids | count(*) |
+---------------+----------+
|            10 |      961 |
|            11 |     1653 |
|            12 |     1998 |
|            13 |     2090 |
|            14 |     1058 |
|            15 |      347 |
...
+---------------+----------+

我可以用狮身人面像得到这样的结果吗?

sphinx
1个回答
1
投票

请确保您使用的是MVA,而不是字符串属性:

index rt
{
    type = rt
    rt_field = f
    rt_attr_multi = education_ids
    path = rt
}

snikolaev@dev:$ mysql -P9306 -h0
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 3.2.2 62ea5ff@191220 release

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> insert into rt(education_ids) values((7,5)), ((7,3)), ((7,1)), ((5,1)), ((5,3));
Query OK, 5 rows affected (0.00 sec)

mysql> select * from rt facet education_ids;
+---------------------+---------------+
| id                  | education_ids |
+---------------------+---------------+
| 2810610458032078849 | 5,7           |
| 2810610458032078850 | 3,7           |
| 2810610458032078851 | 1,7           |
| 2810610458032078852 | 1,5           |
| 2810610458032078853 | 3,5           |
+---------------------+---------------+
5 rows in set (0.00 sec)

+---------------+----------+
| education_ids | count(*) |
+---------------+----------+
|             7 |        3 |
|             5 |        3 |
|             3 |        2 |
|             1 |        2 |
+---------------+----------+
4 rows in set (0.00 sec)

顺便说一句,这是一门有关狮身人面像/ Manticore中刻面的交互式课程,如果您想了解更多有关该方面的知识-https://play.manticoresearch.com/faceting/

© www.soinside.com 2019 - 2024. All rights reserved.