diff --git a/cubicweb_elasticsearch/hooks.py b/cubicweb_elasticsearch/hooks.py index 2902d5c817cf57296ae3f82e53479b7beed394c4_Y3ViaWN3ZWJfZWxhc3RpY3NlYXJjaC9ob29rcy5weQ==..bf3a2a7007d10b04353a986302f691c3eb5189ef_Y3ViaWN3ZWJfZWxhc3RpY3NlYXJjaC9ob29rcy5weQ== 100644 --- a/cubicweb_elasticsearch/hooks.py +++ b/cubicweb_elasticsearch/hooks.py @@ -24,7 +24,7 @@ def entity_indexable(entity): - """ returns boolean to indicate if entity is indexable """ + """returns boolean to indicate if entity is indexable""" return ( entity.cw_etype in indexable_types(entity._cw.vreg.schema) or entity.cw_adapt_to("IFullTextIndexSerializable").custom_indexable_attributes @@ -72,7 +72,7 @@ class IndexEsOperation(hook.DataOperationMixIn, hook.Operation): - """ mixin class to process ES indexing as a postcommit event """ + """mixin class to process ES indexing as a postcommit event""" containercls = list diff --git a/cubicweb_elasticsearch/search_helpers.py b/cubicweb_elasticsearch/search_helpers.py index 2902d5c817cf57296ae3f82e53479b7beed394c4_Y3ViaWN3ZWJfZWxhc3RpY3NlYXJjaC9zZWFyY2hfaGVscGVycy5weQ==..bf3a2a7007d10b04353a986302f691c3eb5189ef_Y3ViaWN3ZWJfZWxhc3RpY3NlYXJjaC9zZWFyY2hfaGVscGVycy5weQ== 100644 --- a/cubicweb_elasticsearch/search_helpers.py +++ b/cubicweb_elasticsearch/search_helpers.py @@ -19,7 +19,7 @@ from elasticsearch_dsl import Q, query as dsl_query -SIMPLE_QUERY_OPERATORS = "|+-\"()*~" +SIMPLE_QUERY_OPERATORS = '|+-"()*~' SIMPLE_QUERY_OPERATORS_RE = r"[\|\+\-\"\(\)\*\~]" @@ -41,8 +41,7 @@ ~N after a word signifies edit distance (fuzziness) ~N after a phrase signifies slop amount - https://www.elastic.co/guide/en/elasticsearch/reference/7.9/query-dsl-simple-query-string-query.html -""" + https://www.elastic.co/guide/en/elasticsearch/reference/7.9/query-dsl-simple-query-string-query.html""" # noqa # for all operators except "-", if it appears, then we assume it is a simple query for operator in SIMPLE_QUERY_OPERATORS.replace("-", ""): if operator in query: @@ -89,10 +88,7 @@ if is_simple_query_string(query): query_string = Q( - "simple_query_string", - query=query, - fields=fields, - default_operator="and" + "simple_query_string", query=query, fields=fields, default_operator="and" ) should.append(query_string) @@ -101,11 +97,7 @@ phrase = common = True if phrase: phrase_query = Q( - "multi_match", - query=query, - type="phrase", - slop=50, - fields=fields + "multi_match", query=query, type="phrase", slop=50, fields=fields ) should.append(phrase_query) # highfrequency/lowfrequency query @@ -125,7 +117,7 @@ elements = re.sub(SIMPLE_QUERY_OPERATORS_RE, " ", query).split() for element in elements: if fuzzy: - should.append(dsl_query.Fuzzy(alltext=element.replace('"', ''))) + should.append(dsl_query.Fuzzy(alltext=element.replace('"', ""))) bool_query = dsl_query.Bool( must=must, must_not=must_not,