Added boost on "title" and "header" fields in Elasticsearch fulltext queries
authorThierry Florac <tflorac@ulthar.net>
Wed, 22 May 2019 14:11:36 +0200
changeset 153 eaf3dbb44a6d
parent 152 c49e9945d241
child 154 301848299b79
Added boost on "title" and "header" fields in Elasticsearch fulltext queries
src/pyams_content_es/shared/view/__init__.py
--- a/src/pyams_content_es/shared/view/__init__.py	Fri Mar 01 14:35:03 2019 +0100
+++ b/src/pyams_content_es/shared/view/__init__.py	Wed May 22 14:11:36 2019 +0200
@@ -164,4 +164,9 @@
                 oid = sequence.get_full_oid(fulltext)
                 yield Q('term', **{'reference_id': oid})
             else:
-                yield Q('simple_query_string', **{'query': fulltext})
+                yield Q('simple_query_string', **{'query': fulltext,
+                                                  'fields': [
+                                                      'title.*^5.0',
+                                                      'header.*^3.0'
+                                                  ]}) | \
+                      Q('simple_query_string', **{'query': fulltext})