Skip to content
Snippets Groups Projects
Commit 9cca1b009006 authored by Arthur Lutz's avatar Arthur Lutz
Browse files

[search_helpers] add Fuzzy search and stop using must

parent ba21ea640706
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from elasticsearch_dsl import Q
from elasticsearch_dsl import Q, query as dsl_query
from logilab.mtconverter import xml_escape
......@@ -41,7 +41,6 @@
must = []
must_not = []
should = []
elements = query.split()
elements_lowercase = [e.lower() for e in elements]
if 'or' in elements_lowercase and len(elements) >= 3:
......@@ -69,9 +68,10 @@
fields=fields))
else:
must.append(Q('multi_match',
query=element,
fields=fields))
should.append(Q('multi_match',
query=element,
fields=fields))
should.append(dsl_query.Fuzzy(_all=element))
return search.query('bool',
must=must,
must_not=must_not,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment