def compile(self, query, postprocess_actions: PostprocessType = None) -> None: bool_head = head_by_path(query, ("query", "script_score", "query", "bool")) if not bool_head.get("must"): bool_head["must"] = [] bool_head["must"] += self.clauses script_score_head = head_by_path(query, ("query", "script_score")) script_score_head["script"] = { "source": "_score / doc['sub_fingerprint_len'].value" } query["min_score"] = 1 postprocess_actions.append(getattr(self, "postprocess"))
def compile(self, query: Dict, postprocess_actions: PostprocessType = None) -> None: bool_head = head_by_path(query, ("query", "script_score", "query", "bool")) if not bool_head.get("should"): bool_head["should"] = [] bool_head["should"] += self.clauses bool_head["minimum_should_match"] = self.min_should_match( len(self.clauses)) script_score_head = head_by_path(query, ("query", "script_score")) script_score_head["script"] = self.script query["min_score"] = self._threshold
def compile(self, query: Dict, postprocess_actions: PostprocessType = None) -> None: # This code same as ExactMatch. # ExactMatch will use search by hash in next releases bool_head = head_by_path(query, ("query", "script_score", "query", "bool")) if not bool_head.get("must"): bool_head["must"] = [] bool_head["must"] += self.clauses script_score_head = head_by_path(query, ("query", "script_score")) script_score_head["script"] = { "source": "_score / doc['sub_fingerprint_len'].value" } query["min_score"] = 1 postprocess_actions.append(getattr(self, "postprocess"))
def default_script_score(query: Dict) -> None: script_score_head = head_by_path( query, ( "query", "script_score", ), ) if not script_score_head.get("script"): script_score_head["script"] = {"source": "_score"}
def compile( self, query: Dict, postprocess_actions: PostprocessType = None ) -> None: bool_head = head_by_path( query, ("query", "script_score", "query", "bool") ) # TODO think about filter if not bool_head.get("must"): bool_head["must"] = [] bool_head["must"].append( {"wildcard": {f"{self.field}": {"wildcard": self.wildcard}}} ) default_script_score(query)
def compile(self, query: Dict, postprocess_actions: PostprocessType = None) -> None: bool_head = head_by_path(query, ("query", "script_score", "query", "bool")) if not bool_head.get("must"): bool_head["must"] = [] bool_head["must"].append( {"match": { self.field: { "query": self._value, "boost": 0 } }}) default_script_score(query)
def compile(self, query: Dict, postprocess_actions: PostprocessType = None) -> None: bool_head = head_by_path(query, ("query", "script_score", "query", "bool")) if not bool_head.get("must"): bool_head["must"] = [] bool_head["must"].append({ "range": { self.field: { "from": self.lower, "to": self.upper, "include_lower": True, "include_upper": True, } } }) default_script_score(query)