Skip to content

Commit

Permalink
remove debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
capjamesg committed Nov 20, 2024
1 parent 3b2d78a commit 8c8183b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions jamesql/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,6 @@ def search(
term_score *= idf

doc["_score"] += term_score

for field in fields:
word_pos = defaultdict(list)

Expand All @@ -933,14 +932,16 @@ def search(
and len(term_queries) > 1
):
first_word_pos = set(word_pos[term_queries[0]])

for i, term in enumerate(term_queries):
positions = set([x - i for x in word_pos[term]])
first_word_pos &= positions

if first_word_pos and field != "title_lower":
doc["_score"] += (
len(first_word_pos) + 1
) # * len(set(word_pos[term_queries[0]]))
)
# * len(set(word_pos[term_queries[0]]))
elif first_word_pos and field == "title_lower":
doc["_score"] *= 2 + len(first_word_pos)

Expand Down Expand Up @@ -1161,18 +1162,15 @@ def _run_get_strict_matches(self, query_term, gsi):
matching_documents = []
matching_positions = {}
words = query_term.split()
print(gsi["warm"])
uuids = set(gsi.get(words[0], {}).get("documents", {}).get("uuid", []))
# only look at documents that contain all words, for efficiency
print(uuids)
for w in query_term.split(" "):
uuids = uuids.intersection(
gsi.get(w, {}).get("documents", {}).get("uuid", [])
)
print(uuids)
for document in uuids:
first_word_pos = set(gsi[words[0]]["documents"]["uuid"][document])
print(first_word_pos)

for i, word in enumerate(words):
word_uuids = gsi[word]["documents"]["uuid"][document]
# subtract i from each position to account for the fact that the first word is at position 0
Expand Down Expand Up @@ -1279,8 +1277,6 @@ def _run(self, query: dict, query_field: str) -> List[str]:
matching_document_scores = {}
matching_highlights = {}

print(query)

query_type = list(
[
key
Expand Down

0 comments on commit 8c8183b

Please sign in to comment.