Skip to content

Commit 7c05aee

Browse files
committed
added the documents with ids method
1 parent 4bd17e0 commit 7c05aee

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Search_Engine/backend.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,16 @@ def find_documents(self, search_term):
104104
if not common_idx_of_docs: # the search term does not exist
105105
return []
106106

107-
# print(common_idx_of_docs)
108-
self._documents_with_idx(common_idx_of_docs)
107+
return self._documents_with_idx(common_idx_of_docs)
109108

110109
def _documents_with_idx(self, idxs):
110+
idxs = list(idxs)
111111
cur = self.conn.cursor()
112-
# reverse_idx = cur.execute("SELECT value FROM IdToDoc WHERE id=(?) or id=(?)", ()).fetchone()[0]
113-
sql="SELECT value FROM IdToDoc WHERE id in ({seq})".format(
112+
sql="SELECT document FROM IdToDoc WHERE id in ({seq})".format(
114113
seq=','.join(['?']*len(idxs))
115-
)
116-
result = cur.execute(sql, idxs)
117-
print(result)
114+
)
115+
result = cur.execute(sql, idxs).fetchall()
116+
return(result)
118117

119118

120119
if __name__ == "__main__":

0 commit comments

Comments
 (0)