Le chat du rabbin
Le chat du rabbin

Reputation: 515

How to search terms containing slash ("/") with Sphinx / Manticore?

I'm trying to find matches of term "/book" and not just "book", but Manticore returns same result for both terms. Index type is rt and charset_table includes slash ("/"). How can I get only "/book" matches?

Upvotes: 0

Views: 406

Answers (1)

Manticore Search
Manticore Search

Reputation: 1482

RT mode

mysql> drop table if exists t; create table t(f text) charset_table = 'non_cjk, /'; insert into t(f) values ('book'), ('/book'); select * from t where match('\\/book'); select * from t where match('book');
--------------
drop table if exists t
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
create table t(f text) charset_table = 'non_cjk, /'
--------------

Query OK, 0 rows affected (0.00 sec)

--------------
insert into t(f) values ('book'), ('/book')
--------------

Query OK, 2 rows affected (0.01 sec)

--------------
select * from t where match('\\/book')
--------------

+---------------------+-------+
| id                  | f     |
+---------------------+-------+
| 1514651075267788906 | /book |
+---------------------+-------+
1 row in set (0.00 sec)

--------------
select * from t where match('book')
--------------

+---------------------+------+
| id                  | f    |
+---------------------+------+
| 1514651075267788905 | book |
+---------------------+------+
1 row in set (0.00 sec)

Plain mode

Plain index

source src {
    type = csvpipe
    csvpipe_command = echo "1,book" && echo "2,/book"
    csvpipe_field = f
}

index idx {
    path = /tmp/idx
    source = src
    charset_table = non_cjk, /
    stored_fields = f
}

searchd {
    listen = 127.0.0.1:9315:mysql41
    log = sphinx_min.log
    pid_file = searchd.pid
    binlog_path =
}
mysql> select * from idx where match('\\/book');
+------+-------+
| id   | f     |
+------+-------+
|    2 | /book |
+------+-------+
1 row in set (0.00 sec)

mysql> select * from idx where match('book');
+------+------+
| id   | f    |
+------+------+
|    1 | book |
+------+------+
1 row in set (0.00 sec)

RT index

index t {
    type = rt
    path = /tmp/idx
    rt_field = f
    charset_table = non_cjk, /
    stored_fields = f
}

searchd {
    listen = 127.0.0.1:9315:mysql41
    log = sphinx_min.log
    pid_file = searchd.pid
    binlog_path =
}
mysql> insert into t(f) values ('book'), ('/book'); select * from t where match('\\/book'); select * from t where match('book');
Query OK, 2 rows affected (0.00 sec)

+---------------------+-------+
| id                  | f     |
+---------------------+-------+
| 1514659513871892482 | /book |
+---------------------+-------+
1 row in set (0.00 sec)

+---------------------+------+
| id                  | f    |
+---------------------+------+
| 1514659513871892481 | book |
+---------------------+------+
1 row in set (0.00 sec)

Upvotes: 2

Related Questions