Skip to content

Commit

Permalink
TairSearch: add tft.explaincost
Browse files Browse the repository at this point in the history
  • Loading branch information
lyq2333 authored and yangbodong22011 committed Apr 10, 2023
1 parent 3d9e1a0 commit 537f7df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tair/tairsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ def tft_analyzer(self, analyzer_name: str, text: str, index: Optional[KeyT] = No
target_nodes = self.nodes_manager.get_node_from_slot(self.keyslot(index))
return self.execute_command("TFT.ANALYZER", *pieces, target_nodes=target_nodes)

def tft_explaincost(self, index: KeyT, query: str) -> ResponseT:
pieces: List[EncodableT] = [index, query]
return self.execute_command("TFT.EXPLAINCOST", *pieces)

def tft_addsug(self, index: KeyT, mapping: Dict[str, int]) -> ResponseT:
pieces: List[EncodableT] = [index]

Expand Down
2 changes: 2 additions & 0 deletions tests/test_tairsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ def test_tft_search(self, t: Tair):
assert json.loads(want) == json.loads(result)
result = t.tft_search(index, '{"sort":[{"price":{"order":"desc"}}]}', True)
assert json.loads(want) == json.loads(result)
result = t.tft_explaincost(index, '{"sort":[{"price":{"order":"desc"}}]}')
assert json.loads(result)['QUERY_COST']
t.delete(index)

def test_tft_msearch(self, t: Tair):
Expand Down

0 comments on commit 537f7df

Please sign in to comment.