Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Missing example for how to do $and and $or filters #68

Open
assembly-winston opened this issue Aug 23, 2024 · 3 comments
Open

[Docs] Missing example for how to do $and and $or filters #68

assembly-winston opened this issue Aug 23, 2024 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@assembly-winston
Copy link

There is no example for how to do these filters in the docs. When doing the suggested example from the general pinecone example and translating to Go, structpb package complains that []map[string]any is not a valid type:

{"$and": [{"genre": "comedy"}, {"genre":"documentary"}]}
@assembly-winston assembly-winston added the documentation Improvements or additions to documentation label Aug 23, 2024
@github-actions github-actions bot added the status:needs-triage An issue that needs to be triaged by the Pinecone team label Aug 23, 2024
@anawishnoff
Copy link
Contributor

@jseldess Would you be able to take a look?

@anawishnoff anawishnoff removed the status:needs-triage An issue that needs to be triaged by the Pinecone team label Oct 1, 2024
@jseldess
Copy link
Contributor

jseldess commented Oct 1, 2024

Sure, @anawishnoff. I'll take a look soon.

@jseldess jseldess self-assigned this Oct 1, 2024
@jseldess
Copy link
Contributor

jseldess commented Oct 2, 2024

@assembly-winston, thanks for reporting this gap in our docs. We'll work on adding SDK-specific filtering examples, but in the meantime, this should work for your example above:

	queryMetadataMap := map[string]interface{}{
		"$and": []interface{}{
			map[string]interface{}{
				"genre": map[string]interface{}{
					"$eq": "comedy",
				},
			},
			map[string]interface{}{
				"genre": map[string]interface{}{
					"$eq": "documentary",
				},
			},
		},
	}

	metadataFilter, err := structpb.NewStruct(queryMetadataMap)
	if err != nil {
		log.Fatalf("Failed to create metadata filter: %v", err)
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants