jurismarches / luqum

A lucene query parser generating ElasticSearch queries and more !
Other
188 stars 40 forks source link

match doesn't return results if default_field is '*' #68

Closed dadokkio closed 3 years ago

dadokkio commented 3 years ago

Hello, I've a strange behavior with full text search.

The parser converts search to something like:

{"query": {"match": {"*": {"query": "test", "zero_terms_query": "none"}}}}

That does not return any result.

Adding a trailing '*' the query is instead converted in this one:

{"query": {"query_string": {"query": "test*", "default_field": "*", "analyze_wildcard": true, "allow_leading_wildcard": true}}}

that correctly returns proper results.

There is a way to have latest behavior also for generic search without trailing ? Like convert to query_string instead of match if field (or default_field) is

thpica commented 3 years ago

Using a multi_match for the * field seems to work for me.

es_query_builder = ElasticsearchQueryBuilder(
    **schema_analyzer.query_builder_options(),
    field_options={"*": {"match_type": "multi_match"}},
)
dadokkio commented 3 years ago

It was easy :) .. I was trying to follow this issue https://github.com/jurismarches/luqum/issues/39 and I was getting partials results but this is way better. Thanks