Skip to content

Commit

Permalink
Issue #1077 and #1085
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Nov 11, 2024
1 parent 7ba1078 commit 48b5e63
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions sde_collections/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def import_sinequa_metadata(modeladmin, request, queryset):
for collection in queryset.all():
# eventually this needs to be done in celery
collection.import_metadata_from_sinequa_config()
collection_names = ", ".join(queryset.values_list("name", flat=True))
messages.add_message(
request,
messages.INFO,
Expand Down
26 changes: 26 additions & 0 deletions sde_collections/sinequa_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,31 @@ def sql_query(self, sql: str) -> Any:
raise Exception(f"API request failed: {str(e)}")

def get_full_texts(self, collection_config_folder: str) -> Any:
'''
Retrieves the full texts, URLs, and titles for a specified collection.
Returns:
dict: A JSON response containing the results of the SQL query in an expected format under the 'Rows' key,
where each item has 'url1', 'text', and 'title' .
Example:
Calling get_full_texts("example_collection") might return:
{
'Rows': [
{
'url1': 'http://example.com/article1',
'text': 'Here is the full text of the first article...',
'title': 'Article One Title'
},
{
'url1': 'http://example.com/article2',
'text': 'Here is the full text of the second article...',
'title': 'Article Two Title'
}
]
}
'''
sql = f"SELECT url1, text, title FROM sde_index WHERE collection = '/SDE/{collection_config_folder}/'"
return self.sql_query(sql)

0 comments on commit 48b5e63

Please sign in to comment.