String filter not working with pluginQPS
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
- initialize orama with QPS plugin
create({
schema: {
title: 'string',
category: 'string',
},
plugins: [pluginQPS()],
})
- insert documents
- search documents in the db
orama.search(db, {
term: 'Harry',
where: {
category: ['movie', 'book']
}
})
- 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
@allevo any idea?
Hi! No idea. Can you also give us some documents you insert?
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)
@allevo is there any news?
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?
Hey, with the new v3.1.10 of the @orama/plugin-qps, it should work fine.
Closed as fixed in v3.1.10