Search the top K semantically similar records
Search the top K semantically similar records
status_code, response = db.query(
table_name="MyTable", # The name of the table to query against.
query_index="Index", # The index name to query against.
query_text="Where can I find a serene environment, ideal for relaxation and introspection?",
# The query question.
limit=2, # The top K result to return.
response_fields=["Doc"], # (Optional) which fields to be included in
# the response. If not provided, will include
# all fields in the table.
filter="ID < 6 AND Doc <> 'London'", # (Optional) a boolean expression for filtering
# out the results.
with_distance=True # (Optional) include the distance or not in
# the response. Default is False. When given
# as True, each matched record will have a
# @distance field returned.
)
print(response){
'message': 'Query search successfully.',
'result': [
{
'@distance': 0.4707561135292053,
'Doc': 'The library was a quiet haven, filled with the scent of old books and the soft rustling of pages.',
'ID': 3
},
{
'@distance': 0.47871750593185425,
'Doc': 'High in the mountains, the air was crisp and clear, revealing breathtaking views of the valley below.',
'ID': 4
}
],
'statusCode': 200
}Filter Expression
Operator
Description
Filter on @distance
Last updated