orama icon indicating copy to clipboard operation
orama copied to clipboard

String filter not working with pluginQPS

Open FabioNappi opened this issue 7 months ago • 4 comments

Describe the bug

I have an Orama db with a string property in its schema and the QPS plugin enabled. When I perform a search with an array valued where clause on the string property (just like the second example in the docs) it finds no documents.

To Reproduce

  1. initialize orama with QPS plugin
create({
  schema: {
    title: 'string',
    category: 'string',
  },
  plugins: [pluginQPS()],
})
  1. insert documents
  2. search documents in the db
orama.search(db, {
  term: 'Harry',
  where: {
    category: ['movie', 'book']
  }
})
  1. the result is no documents found

Expected behavior

I expect to actually find documents with category = 'movie' OR category = 'book', but got none.

Environment Info

OS: MacOS 15.4
Node: 22.14.0
Orama: 3.1.6

Affected areas

Search

Additional context

No response

FabioNappi avatar May 15 '25 12:05 FabioNappi

@allevo any idea?

micheleriva avatar May 17 '25 04:05 micheleriva

Hi! No idea. Can you also give us some documents you insert?

allevo avatar May 17 '25 09:05 allevo

Hello! Here it is a complete code snippet example to reproduce the bug. If you try to comment the plugin line, the search will actually return both documents

import {create, insertMultiple, search} from '@orama/orama'
import {pluginQPS} from '@orama/plugin-qps'

const db = create({
  schema: {
    title: 'string',
    category: 'string',
  },
  plugins: [pluginQPS()],
})

await insertMultiple(db, [
  {
    title: `Harry Potter and the Philosopher's Stone`,
    category: 'movie',
  },
  {
    title: 'Harry Potter and the Chamber of Secrets',
    category: 'book',
  },
])

const found = await search(db, {
  term: 'Harry',
  where: {
    category: ['movie', 'book'],
  },
})

console.log(found)

FabioNappi avatar May 17 '25 10:05 FabioNappi

@allevo is there any news?

FabioNappi avatar May 28 '25 15:05 FabioNappi

I've found that the pluginQPS doesn't even match Orama's own types:

Type 'OramaPluginSync' is not assignable to type 'OramaPlugin'.
  Type 'OramaPluginSync' is not assignable to type 'OramaPluginSync<unknown>'.
    Types of property 'beforeInsert' are incompatible.

The docs are wrong:

import { create } from '@orama/orama'
import { pluginQPS } from '@orama/plugin-qps'

const db = create({
  schema: {
    title: 'string',
    description: 'string',
    rating: 'number',
  },
  plugins: [pluginQPS()],
})

I believe this is the correct usage:

import { create } from '@orama/orama'
import { pluginQPS } from '@orama/plugin-qps'

const db = create({
  schema: {
    title: 'string',
    description: 'string',
    rating: 'number',
  },
  plugins: [pluginQPS],
})

@niltonheck @raiindev @micheleriva Any comment?

isaachinman avatar Jun 30 '25 19:06 isaachinman

Hey, with the new v3.1.10 of the @orama/plugin-qps, it should work fine.

raiindev avatar Jul 02 '25 14:07 raiindev

Closed as fixed in v3.1.10

micheleriva avatar Jul 12 '25 19:07 micheleriva