lancedb_haystack.conversion.lancedb_to_python

Functions

convert_lancedb_to_document(→ haystack.Document)

Convert a lancedb result into a document

convert_field(→ Any)

Converts the value of a field from it's representation in LanceDB to the one used for Haystack

convert_struct(→ dict)

Converts the metadata section of the LanceDB representation of a Document to a Haystack Document.

convert_timestamp(value, field_type)

Convert timestamp values to isoformat as expected by Haystack

Module Contents

lancedb_haystack.conversion.lancedb_to_python.convert_lancedb_to_document(result: dict, schema: pyarrow.Schema) haystack.Document

Convert a lancedb result into a document

Parameters:
  • result – the result from the LanceDB query

  • schema – the lancedb table schema

Returns:

a haystack Document

lancedb_haystack.conversion.lancedb_to_python.convert_field(value: Any, field_type: pyarrow.DataType) Any

Converts the value of a field from it’s representation in LanceDB to the one used for Haystack

Parameters:
  • value – the value to convert

  • field_type – The pyarrow type of the value, so we know how to convert it.

Returns:

the converted value

lancedb_haystack.conversion.lancedb_to_python.convert_struct(value: dict, field_type: pyarrow.StructType) dict

Converts the metadata section of the LanceDB representation of a Document to a Haystack Document.

This involves filtering out empty fields, as well as handling some type conversions to ensure that it complies with the expected Haystack DocumentStore behaviour.

Parameters:
  • value – the value to convert

  • field_type – The pyarrow type of the value, so we know how to convert it.

Returns:

the converted value

lancedb_haystack.conversion.lancedb_to_python.convert_timestamp(value: datetime.datetime, field_type: pyarrow.DataType)

Convert timestamp values to isoformat as expected by Haystack

Parameters:
  • value – the value to convert

  • field_type – The pyarrow type of the value, in this case, is ignored.

Returns:

the converted value