Skip to content

Commit fd3c4f0

Browse files
committed
Add last modified date
1 parent 7aaab9a commit fd3c4f0

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

deploy_ai_search/rag_documents.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ def get_index_fields(self) -> list[SearchableField]:
9696
filterable=True,
9797
facetable=True,
9898
),
99+
SimpleField(
100+
name="DateLastModified",
101+
type=SearchFieldDataType.DateTimeOffset,
102+
filterable=True,
103+
),
99104
]
100105

101106
if self.enable_page_by_chunking:
@@ -193,6 +198,9 @@ def get_index_projections(self) -> SearchIndexerIndexProjections:
193198
InputFieldMappingEntry(
194199
name="Sections", source="/document/pages/*/cleaned_sections"
195200
),
201+
InputFieldMappingEntry(
202+
name="DateLastModified", source="/document/DateLastModified"
203+
),
196204
]
197205

198206
if self.enable_page_by_chunking:
@@ -269,6 +277,10 @@ def get_indexer(self) -> SearchIndexer:
269277
source_field_name="metadata_storage_path",
270278
target_field_name="SourceUri",
271279
),
280+
FieldMapping(
281+
source_field_name="metadata_storage_last_modified",
282+
target_field_name="DateLastModified",
283+
),
272284
],
273285
parameters=indexer_parameters,
274286
)

deploy_ai_search/text_2_sql.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ def get_index_fields(self) -> list[SearchableField]:
9494
collection=True,
9595
hidden=True,
9696
), # This is needed to enable semantic searching against the column names as complex field types are not used.
97+
SimpleField(
98+
name="DateLastModified",
99+
type=SearchFieldDataType.DateTimeOffset,
100+
filterable=True,
101+
),
97102
]
98103

99104
return fields
@@ -177,6 +182,12 @@ def get_indexer(self) -> SearchIndexer:
177182
target_index_name=self.index_name,
178183
data_source_name=self.data_source_name,
179184
schedule=schedule,
185+
field_mappings=[
186+
FieldMapping(
187+
source_field_name="metadata_storage_last_modified",
188+
target_field_name="DateLastModified",
189+
)
190+
],
180191
output_field_mappings=[
181192
FieldMapping(
182193
source_field_name="/document/Entity", target_field_name="Entity"
@@ -201,6 +212,9 @@ def get_indexer(self) -> SearchIndexer:
201212
source_field_name="/document/Columns/*/Name",
202213
target_field_name="ColumnNames",
203214
),
215+
FieldMapping(
216+
name="DateLastModified", source="/document/DateLastModified"
217+
),
204218
],
205219
parameters=indexer_parameters,
206220
)

deploy_ai_search/text_2_sql_query_cache.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ def get_index_fields(self) -> list[SearchableField]:
9797
),
9898
],
9999
),
100+
SimpleField(
101+
name="DateLastModified",
102+
type=SearchFieldDataType.DateTimeOffset,
103+
filterable=True,
104+
),
100105
]
101106

102107
return fields

text_2_sql/ai_search.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import logging
1111
import base64
12+
from datetime import datetime, timezone
1213

1314

1415
async def run_ai_search_query(
@@ -87,6 +88,8 @@ async def add_entry_to_index(document: dict, vector_fields: dict, index_name: st
8788

8889
fields_to_embed = {field: document[field] for field in vector_fields}
8990

91+
document["DateLastModified"] = datetime.now(timezone.utc)
92+
9093
async with AsyncAzureOpenAI(
9194
# This is the default and can be omitted
9295
api_key=os.environ["OpenAI__ApiKey"],

0 commit comments

Comments
 (0)