Skip to content

Error when using Postgres Index #218

@ollyw

Description

@ollyw

Describe the bug
The pgvector index creates malformed queries.

To Reproduce
Steps to reproduce the behavior:

  1. Run postgresql with pgvector
  2. execute https://github.com/henomis/lingoose/blob/main/examples/embeddings/postgres/main.go
  3. A panic happens in the test with the error "internal index error: pq: syntax error at or near "<=>""

Expected behavior
The query works and outputs the purpose of Nato (as per the question)

Potential fix
It looks like the query parameters are swapped round. Simply changing them causes it to start working. In order to check it works with a non-empy filter also, the query was modified like so:

	similarities, err := index.Query(
		context.Background(),
		query,
		indexoption.WithTopK(3),
		indexoption.WithFilter("where metadata->>'source' = 'state_of_the_union.txt'"),
	)

This executed fine. Then updating the row with Nato in to be a difference source caused the down to be excluded, as expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions