Make the search more flexible

This commit is contained in:
Mark Veidemanis 2022-07-21 13:49:17 +01:00
parent 424f8381d3
commit aec3e2c408
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
3 changed files with 23 additions and 1 deletions

View File

@ -29,9 +29,29 @@ def construct_query(query, fields, results):
query = {
"size": results,
"query": {
"multi_match": {
"query_string": {
"query": query,
"fields": fields,
# "default_field": "msg",
# "type": "best_fields",
"fuzziness": "AUTO",
"fuzzy_transpositions": True,
"fuzzy_max_expansions": 50,
"fuzzy_prefix_length": 0,
"minimum_should_match": 1,
"default_operator": "or",
"analyzer": "standard",
"lenient": False,
"boost": 1,
"allow_leading_wildcard": True,
"enable_position_increments": False,
"phrase_slop": 3,
"max_determinized_states": 10000,
"time_zone": "-08:00",
"quote_field_suffix": "",
"quote_analyzer": "standard",
"analyze_wildcard": True,
"auto_generate_synonyms_phrase_query": True,
}
},
}

View File

@ -142,5 +142,6 @@
</div>
{% if results is not None %}
<p>{{ card }} hits</p>
<p>{{ took }}ms</p>
{% endif %}
{% endblock %}

View File

@ -46,6 +46,7 @@ class Drilldown(LoginRequiredMixin, View):
"query": query,
"results": results_parsed,
"card": results["hits"]["total"]["value"],
"took": results["took"],
"fields": settings.OPENSEARCH_MAIN_SEARCH_FIELDS,
}
return render(request, self.template_name, context)