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

Implements enum[] #482

Merged
merged 8 commits into from
Sep 19, 2023
Merged

Implements enum[] #482

merged 8 commits into from
Sep 19, 2023

Conversation

allevo
Copy link
Collaborator

@allevo allevo commented Sep 18, 2023

With this PR, I want to introduce the enum[] as the follower of #458

So,

const db = await create({
  schema: {
   colors: 'enum[]',
  },
})
await insertMultiple(db, [
  {colors: ['green', 'red'] },
  {colors: ['green'] },
  {colors: ['blue', 'white'] },
])

const resultContains = await search(db, {
  term: '',
  where: {
    colors: { contains: 'green' },
  }
}) // Expected 2 results: 1° and 2°
const resultIntersects = await search(db, {
  term: '',
  where: {
    colors: { intersects: ['red', 'blue'] },
  }
}) // Expected 2 results: 1° and 3°

This PR introduces contains, and intersects operators because they are more appropriate for arrays.

  • implementation
  • documentation
  • tests
  • facets for enum and enum[]
  • feedback

@vercel
Copy link

vercel bot commented Sep 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orama-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 19, 2023 4:00pm

Copy link
Member

@micheleriva micheleriva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good to me. I just left a couple of small comments. Since we're operating on arrays, I would use a unique keyword contains, where the value is either polymorphic (string or array of strings), or monomorphic (contains must include an array of 1 element).

packages/docs/pages/usage/create.mdx Outdated Show resolved Hide resolved
packages/docs/pages/usage/search/filters.mdx Outdated Show resolved Hide resolved
packages/orama/src/components/facets.ts Outdated Show resolved Hide resolved
@allevo
Copy link
Collaborator Author

allevo commented Sep 19, 2023

Implement just containsAll operator

Copy link
Member

@micheleriva micheleriva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. In the future we might want to add another PR to implement a function for intersection

@micheleriva micheleriva merged commit 40562cc into main Sep 19, 2023
2 checks passed
@micheleriva micheleriva deleted the feat/enum-arr branch September 19, 2023 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants