Skip to content

simple_query_string #1322

@TKassis

Description

@TKassis

I'm having issues using "simple_query_string".

The following works:

q = Q("match", body = {"query": search_term, "operator": "and", "fuzziness": 'auto'}) 
s = Search(using=client, index="testindex")
s = s.query(q)
response = s.execute()

But not this:

q = Q("simple_query_string", body = {"query": search_term, "fields": ["body"]})
s = Search(using=client, index="testindex")
s = s.query(q)
response = s.execute()

I get the following error:

RequestError: RequestError(400, 'parsing_exception', '[simple_query_string] unknown token [START_OBJECT] after [body]')
Traceback:
File "c:\users\timothy\miniconda3\envs\drugfda\lib\site-packages\streamlit\ScriptRunner.py", line 314, in _run_script
exec(code, module.dict)
File "D:\Documents\Python Projects\Drugs@FDA\fdadocsearch.py", line 59, in
response = s.execute()
File "c:\users\timothy\miniconda3\envs\drugfda\lib\site-packages\elasticsearch_dsl\search.py", line 698, in execute
**self._params
File "c:\users\timothy\miniconda3\envs\drugfda\lib\site-packages\elasticsearch\client\utils.py", line 84, in wrapped
return func(*args, params=params, **kwargs)
File "c:\users\timothy\miniconda3\envs\drugfda\lib\site-packages\elasticsearch\client_init
.py", line 1548, in search
"GET", _make_path(index, doc_type, "_search"), params=params, body=body
File "c:\users\timothy\miniconda3\envs\drugfda\lib\site-packages\elasticsearch\transport.py", line 358, in perform_request
timeout=timeout,
File "c:\users\timothy\miniconda3\envs\drugfda\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 261, in perform_request
self._raise_error(response.status, raw_data)
File "c:\users\timothy\miniconda3\envs\drugfda\lib\site-packages\elasticsearch\connection\base.py", line 182, in _raise_error
status_code, error_message, additional_info

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions