Skip to content

Commit

Permalink
work on query engine
Browse files Browse the repository at this point in the history
  • Loading branch information
capjamesg committed Aug 22, 2024
1 parent b5934d6 commit 0ab1958
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions jamesql/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _close_to(self, query: list) -> dict:

stride_range = range(-stride, stride + 1)

if gsi["strategy"] == GSI_INDEX_STRATEGIES.CONTAINS:
if gsi["strategy"] == GSI_INDEX_STRATEGIES.CONTAINS.name:
for doc_id, positions in current_word_positions.items():
if doc_id not in previous_word_positions:
continue
Expand Down Expand Up @@ -179,9 +179,9 @@ def add(self, document: list, doc_id=None) -> Dict[str, dict]:
if doc_id:
document["uuid"] = doc_id
else:
doc_uuid = uuid.uuid4().hex
document["uuid"] = uuid.uuid4().hex

self.global_index[doc_uuid] = document
self.global_index[document["uuid"]] = document

self.uuids_to_position_in_global_index[document["uuid"]] = (
len(self.global_index) - 1
Expand Down Expand Up @@ -263,7 +263,7 @@ def create_gsi(
+ "."
)

self.gsis[index_by] = {"gsi": gsi, "strategy": strategy}
self.gsis[index_by] = {"gsi": gsi, "strategy": strategy.name}

return gsi

Expand Down Expand Up @@ -445,7 +445,8 @@ def _run(self, query: dict, query_field: str) -> List[str]:
if not self.gsis.get(query_field):
self.create_gsi(query_field, GSI_INDEX_STRATEGIES.FLAT)

gsi_type = self.gsis[query_field]["strategy"]
gsi_type = GSI_INDEX_STRATEGIES[self.gsis[query_field]["strategy"]]

gsi = self.gsis[query_field]["gsi"]

fuzzy = query["query"][query_field].get("fuzzy", False)
Expand Down

0 comments on commit 0ab1958

Please sign in to comment.