Skip to content

Commit 56b12d0

Browse files
committed
Update indexer code
1 parent b022f4f commit 56b12d0

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

deploy_ai_search/deploy.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def deploy_config(arguments: argparse.Namespace):
2222
)
2323
elif arguments.index_type == "text_2_sql":
2424
index_config = Text2SqlAISearch(
25-
suffix=arguments.suffix, rebuild=arguments.rebuild
25+
suffix=arguments.suffix,
26+
rebuild=arguments.rebuild,
27+
single_data_dictionary=arguments.single_data_dictionary,
2628
)
2729
elif arguments.index_type == "text_2_sql_query_cache":
2830
index_config = Text2SqlQueryCacheAISearch(
@@ -57,6 +59,12 @@ def deploy_config(arguments: argparse.Namespace):
5759
required=False,
5860
help="Whether want to enable chunking by page in adi skill, if no value is passed considered False",
5961
)
62+
parser.add_argument(
63+
"--single_data_dictionary",
64+
type=bool,
65+
required=False,
66+
help="Whether or not a single data dictionary file should be uploaded, or one per entity",
67+
)
6068
parser.add_argument(
6169
"--suffix",
6270
type=str,

deploy_ai_search/rag_documents.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,17 @@ def get_index_fields(self) -> list[SearchableField]:
101101
name="Figures",
102102
collection=True,
103103
fields=[
104-
SimpleField(
104+
SearchableField(
105105
name="FigureId",
106106
type=SearchFieldDataType.String,
107107
collection=True,
108+
searchable=False,
108109
),
109-
SimpleField(
110+
SearchableField(
110111
name="FigureUri",
111112
type=SearchFieldDataType.String,
112113
collection=True,
114+
searchable=False,
113115
),
114116
],
115117
),

deploy_ai_search/text_2_sql.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
BlobIndexerDataToExtract,
1919
IndexerExecutionEnvironment,
2020
BlobIndexerParsingMode,
21+
FieldMappingFunction,
2122
)
2223
from ai_search import AISearch
2324
from environment import (
@@ -28,7 +29,12 @@
2829
class Text2SqlAISearch(AISearch):
2930
"""This class is used to deploy the sql index."""
3031

31-
def __init__(self, suffix: str | None = None, rebuild: bool | None = False):
32+
def __init__(
33+
self,
34+
suffix: str | None = None,
35+
rebuild: bool | None = False,
36+
single_data_dictionary: bool | None = False,
37+
):
3238
"""Initialize the Text2SqlAISearch class. This class implements the deployment of the sql index.
3339
3440
Args:
@@ -38,7 +44,10 @@ def __init__(self, suffix: str | None = None, rebuild: bool | None = False):
3844
self.indexer_type = IndexerType.TEXT_2_SQL
3945
super().__init__(suffix, rebuild)
4046

41-
self.parsing_mode = BlobIndexerParsingMode.JSON_ARRAY
47+
if single_data_dictionary:
48+
self.parsing_mode = BlobIndexerParsingMode.JSON_ARRAY
49+
else:
50+
self.parsing_mode = BlobIndexerParsingMode.JSON
4251

4352
def get_index_fields(self) -> list[SearchableField]:
4453
"""This function returns the index fields for sql index.
@@ -47,10 +56,15 @@ def get_index_fields(self) -> list[SearchableField]:
4756
list[SearchableField]: The index fields for sql index"""
4857

4958
fields = [
59+
SimpleField(
60+
name="Id",
61+
type=SearchFieldDataType.String,
62+
key=True,
63+
analyzer_name="keyword",
64+
),
5065
SearchableField(
5166
name="Entity",
5267
type=SearchFieldDataType.String,
53-
key=True,
5468
analyzer_name="keyword",
5569
),
5670
SearchableField(
@@ -76,15 +90,17 @@ def get_index_fields(self) -> list[SearchableField]:
7690
SearchableField(name="Name", type=SearchFieldDataType.String),
7791
SearchableField(name="Definition", type=SearchFieldDataType.String),
7892
SearchableField(name="Type", type=SearchFieldDataType.String),
79-
SimpleField(
93+
SearchableField(
8094
name="AllowedValues",
8195
type=SearchFieldDataType.String,
8296
collection=True,
97+
searchable=False,
8398
),
84-
SimpleField(
99+
SearchableField(
85100
name="SampleValues",
86101
type=SearchFieldDataType.String,
87102
collection=True,
103+
searchable=False,
88104
),
89105
],
90106
),
@@ -190,6 +206,14 @@ def get_indexer(self) -> SearchIndexer:
190206
)
191207
],
192208
output_field_mappings=[
209+
FieldMapping(
210+
source_field_name="/document/Entity",
211+
target_field_name="Id",
212+
mapping_function=FieldMappingFunction(
213+
name="base64Encode",
214+
parameters={"useHttpServerUtilityUrlTokenEncode": False},
215+
),
216+
),
193217
FieldMapping(
194218
source_field_name="/document/Entity", target_field_name="Entity"
195219
),

deploy_ai_search/text_2_sql_query_cache.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,17 @@ def get_index_fields(self) -> list[SearchableField]:
7777
SearchableField(
7878
name="Type", type=SearchFieldDataType.String
7979
),
80-
SimpleField(
80+
SearchableField(
8181
name="AllowedValues",
8282
type=SearchFieldDataType.String,
8383
collection=True,
84+
searchable=False,
8485
),
85-
SimpleField(
86+
SearchableField(
8687
name="SampleValues",
8788
type=SearchFieldDataType.String,
8889
collection=True,
90+
searchable=False,
8991
),
9092
],
9193
),

0 commit comments

Comments
 (0)