manticoresoftware / manticoresearch

Easy to use open source fast database for search | Good alternative to Elasticsearch now | Drop-in replacement for E in the ELK soon
https://manticoresearch.com
GNU General Public License v3.0
8.93k stars 494 forks source link

ERROR 1064 (42000): unknown option 'fuzzy' #2581

Open zepen opened 5 days ago

zepen commented 5 days ago

Proposal:

run sql as below

SELECT * FROM test2 WHERE MATCH('helo') OPTION fuzzy=1;

version as below

Manticore 6.3.6 593045790@24080214 (columnar 2.3.0 88a01c3@24052206) (secondary 2.3.0 88a01c3@24052206) (knn 2.3.0 88a01c3@24052206)
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2024, Manticore Software LTD (https://manticoresearch.com)

but logs outputs:

MySQL [(none)]> SELECT * FROM test2 WHERE MATCH('helo') OPTION fuzzy=1;
ERROR 1064 (42000): unknown option 'fuzzy'

Checklist:

To be completed by the assignee. Check off tasks that have been completed or are not applicable.

- [x] Implementation completed - [ ] Tests developed - [ ] Documentation updated - [ ] Documentation reviewed - [ ] [Changelog](https://docs.google.com/spreadsheets/d/1mz_3dRWKs86FjRF7EIZUziUDK_2Hvhd97G0pLpxo05s/edit?pli=1&gid=1102439133#gid=1102439133) updated - [x] OpenAPI YAML updated and issue created to rebuild clients
djklim87 commented 5 days ago

Hello. Did you install Buddy?

sanikolaev commented 5 days ago

The fuzzy option is not released yet. Please use the dev version https://mnt.cr/dev/nightly

zepen commented 4 days ago

thanks! but old tables how to set min_infix_len

ERROR 1064 (42000): Fuzzy plugin requires min_infix_len to be set
zepen commented 4 days ago

and python sdk have error

2024-09-22 16:04:01.048 | ERROR    | manticore_search:search_by_sql:31 - manticore-search-error:search-by-sql:0
sanikolaev commented 4 days ago

but old tables how to set min_infix_len

Use ALTER TABLE

Note, it will affect only new documents. For full reindexing of the table you can use mysqldump - mysqldump -etc --replace ....

and python sdk have error

What's the code?

zepen commented 3 days ago

but old tables how to set min_infix_len

Use ALTER TABLE

Note, it will affect only new documents. For full reindexing of the table you can use mysqldump - mysqldump -etc --replace ....

and python sdk have error

What's the code?

import manticoresearch
from manticoresearch.rest import ApiException
from manticore_search import ManticoreSearch
from loguru import logger

class ManticoreSearch:

    def __init__(self, host, logger):
        self._logger = logger
        configuration = manticoresearch.Configuration(host=host)
        api_client = manticoresearch.ApiClient(configuration)
        self.index_api = manticoresearch.IndexApi(api_client)
        self.search_api = manticoresearch.SearchApi(api_client)
        self.utils_api = manticoresearch.UtilsApi(api_client)

manticore_search = ManticoreSearch("127.0.0.1:9308", logger)
sql = """select * from my_index where match('temu') OPTION fuzzy=1 layouts='us,uk' distance=2;"""
manticore_search.utils_api.sql(sql)

but have error :

{'error': "P01: syntax error, unexpected $end near ', '"}

single run sql its work well when i use mysql -P9306 -h0 login systems

sanikolaev commented 3 days ago

Can't reproduce your error, but I had to remove from manticore_search import ManticoreSearch from your script:

snikolaev@dev2:~$ pip install manticoresearch loguru
Defaulting to user installation because normal site-packages is not writeable
Collecting manticoresearch
  Using cached manticoresearch-4.0.0-py3-none-any.whl (112 kB)
Requirement already satisfied: loguru in ./.local/lib/python3.10/site-packages (0.7.2)
Requirement already satisfied: urllib3>=1.15 in /usr/lib/python3/dist-packages (from manticoresearch) (1.26.5)
Requirement already satisfied: six>=1.10 in /usr/lib/python3/dist-packages (from manticoresearch) (1.16.0)
Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from manticoresearch) (2024.7.4)
Requirement already satisfied: python-dateutil in ./.local/lib/python3.10/site-packages (from manticoresearch) (2.8.2)
Installing collected packages: manticoresearch
Successfully installed manticoresearch-4.0.0

[notice] A new release of pip is available: 23.1.2 -> 24.2
[notice] To update, run: python -m pip install --upgrade pip
snikolaev@dev2:~$ cat 2581.py
import manticoresearch
from manticoresearch.rest import ApiException
from loguru import logger

class ManticoreSearch:

    def __init__(self, host, logger):
        self._logger = logger
        configuration = manticoresearch.Configuration(host=host)
        api_client = manticoresearch.ApiClient(configuration)
        self.index_api = manticoresearch.IndexApi(api_client)
        self.search_api = manticoresearch.SearchApi(api_client)
        self.utils_api = manticoresearch.UtilsApi(api_client)

manticore_search = ManticoreSearch("127.0.0.1:9308", logger)
sql = """select * from my_index where match('temu') OPTION fuzzy=1 layouts='us,uk' distance=2;"""
manticore_search.utils_api.sql(sql)
snikolaev@dev2:~$ mysql -P9306 -h0 -e "drop table if exists my_index; create table my_index(f text) min_infix_len='2';"
snikolaev@dev2:~$ python3 2581.py

Please provide a better instruction how to reproduce the issue.

My versions are:

snikolaev@dev2:~$ searchd -v
Manticore 6.3.7 53ae190b8@24091306 dev (columnar 2.3.1 f9ef8b9@24090411) (secondary 2.3.1 f9ef8b9@24090411) (knn 2.3.1 f9ef8b9@24090411)

snikolaev@dev2:~$ python3 --version
Python 3.10.12
zepen commented 3 days ago

Can't reproduce your error, but I had to remove from manticore_search import ManticoreSearch from your script:

snikolaev@dev2:~$ pip install manticoresearch loguru
Defaulting to user installation because normal site-packages is not writeable
Collecting manticoresearch
  Using cached manticoresearch-4.0.0-py3-none-any.whl (112 kB)
Requirement already satisfied: loguru in ./.local/lib/python3.10/site-packages (0.7.2)
Requirement already satisfied: urllib3>=1.15 in /usr/lib/python3/dist-packages (from manticoresearch) (1.26.5)
Requirement already satisfied: six>=1.10 in /usr/lib/python3/dist-packages (from manticoresearch) (1.16.0)
Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from manticoresearch) (2024.7.4)
Requirement already satisfied: python-dateutil in ./.local/lib/python3.10/site-packages (from manticoresearch) (2.8.2)
Installing collected packages: manticoresearch
Successfully installed manticoresearch-4.0.0

[notice] A new release of pip is available: 23.1.2 -> 24.2
[notice] To update, run: python -m pip install --upgrade pip
snikolaev@dev2:~$ cat 2581.py
import manticoresearch
from manticoresearch.rest import ApiException
from loguru import logger

class ManticoreSearch:

    def __init__(self, host, logger):
        self._logger = logger
        configuration = manticoresearch.Configuration(host=host)
        api_client = manticoresearch.ApiClient(configuration)
        self.index_api = manticoresearch.IndexApi(api_client)
        self.search_api = manticoresearch.SearchApi(api_client)
        self.utils_api = manticoresearch.UtilsApi(api_client)

manticore_search = ManticoreSearch("127.0.0.1:9308", logger)
sql = """select * from my_index where match('temu') OPTION fuzzy=1 layouts='us,uk' distance=2;"""
manticore_search.utils_api.sql(sql)
snikolaev@dev2:~$ mysql -P9306 -h0 -e "drop table if exists my_index; create table my_index(f text) min_infix_len='2';"
snikolaev@dev2:~$ python3 2581.py

Please provide a better instruction how to reproduce the issue.

My versions are:

snikolaev@dev2:~$ searchd -v
Manticore 6.3.7 53ae190b8@24091306 dev (columnar 2.3.1 f9ef8b9@24090411) (secondary 2.3.1 f9ef8b9@24090411) (knn 2.3.1 f9ef8b9@24090411)

snikolaev@dev2:~$ python3 --version
Python 3.10.12

My version:

Manticore 6.3.7 d938571ca@24091913 dev (columnar 2.3.1 f9ef8b9@24090411) (secondary 2.3.1 f9ef8b9@24090411) (knn 2.3.1 f9ef8b9@24090411)
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2024, Manticore Software LTD (https://manticoresearch.com)

Python 3.11.4

And python code:

import manticoresearch
from manticoresearch.rest import ApiException
from loguru import logger

class ManticoreSearch:

    def __init__(self, host, logger):
        self._logger = logger
        configuration = manticoresearch.Configuration(host=host)
        api_client = manticoresearch.ApiClient(configuration)
        self.index_api = manticoresearch.IndexApi(api_client)
        self.search_api = manticoresearch.SearchApi(api_client)
        self.utils_api = manticoresearch.UtilsApi(api_client)

manticore_search = ManticoreSearch("127.0.0.1:9308", logger)
sql = """select * from test_index where match('temu') OPTION fuzzy=1 layouts='us,uk' distance=2;"""
data = manticore_search.utils_api.sql(sql)
print(data)

build test-index like this:

mysql -P9306 -h0 -e "drop table if exists test_index; create table test_index(f text) min_infix_len='2';"

python script name same with u

logs show:

python 2518.py 

{'error': "P01: syntax error, unexpected $end near ', '"}

In python core, It wasn't queried correctly. Maybe the SQL statement cannot be parsed.

sanikolaev commented 2 days ago

3 questions:

  1. Why this select * from test_index where match('temu') OPTION fuzzy=1 layouts='us,uk' distance=2; works via mysql client and doesn't work via the python client (and probably /sql)
  2. Why this doesn't fail (there's no commas):
    mysql> select * from test_index where match('temu') OPTION fuzzy=1 layouts='us,uk' distance=2;
    Empty set (0.01 sec)
  3. If I remove layouts='us,uk' from the sql query it doesn't fail via the python client
sanikolaev commented 2 days ago

@donhardman as discussed, pls try to answer the above questions.