oramasearch / orama

🌌 A complete search engine and RAG pipeline in your browser, server or edge network with support for full-text, vector, and hybrid search in less than 2kb.
https://docs.orama.com
Other
8.77k stars 296 forks source link

Support for nested properties #14

Closed micheleriva closed 2 years ago

micheleriva commented 2 years ago

Is your feature request related to a problem? Please describe. As for now, Lyra does not support nested properties. Thus, the following code will break:

import { lyra } from '@nearfom/lyra';

const movieDB = new Lyra({
  schema: {
    title: 'string',
    director: 'string',
    plot: 'string',
    year: 'number',
    isFavorite: 'boolean',
    cast: { // <-------- objects are not supported yet
      director: 'string',
      leading: 'string'
    }
  }
});

We should grant support for nested properties to Lyra

DanieleFedeli commented 2 years ago

Can I pick this up? I promise nothing since I never looked at the source code but I would like to try it

micheleriva commented 2 years ago

Go for it 🙂

DanieleFedeli commented 2 years ago

Schema type is not propagated throughout Lyra instance. Is this a design choice?

micheleriva commented 2 years ago

What do you mean by that?

DanieleFedeli commented 2 years ago

I mean when I create an instance with a specific schema like that:

const db = new Lyra({ schema: { quote: "string",  author: "string" }});

The insert method does not inherit the type from the schema passed So If I do:

await db.insert({ nonExistingField: "A_RANDOM_STRING"});

I will get INVALID_DOC_SCHEMA, This error is only raised at runtime, but at compile time it is not detected.

micheleriva commented 2 years ago

@DanieleFedeli got it, this is a missing feature that I'd definitely love to have!

DanieleFedeli commented 2 years ago

I can work on that also, but now I am focusing on this one 😆