orama icon indicating copy to clipboard operation
orama copied to clipboard

Search with `exact: true` doesn't work as intended

Open zeroliu opened this issue 11 months ago β€’ 21 comments

Describe the bug

When I search with exact: true, documents with partially matching terms are also returned.

To Reproduce

https://codesandbox.io/p/sandbox/lvy7mc

const db = create({
  schema: {
    path: "string",
    title: "string",
  },
});

insert(db, { path: "First Note.md", title: "First Note" });
insert(db, { path: "Second Note.md", title: "Second Note" });

const noExact = search(db, {
  term: "first",
  properties: ["path"],
}); // 1 result OK
const withExact = search(db, {
  term: "first",
  properties: ["path"],
  exact: true,
}); // 1 result NOT OK

console.log("noExact path", noExact);
console.log("withExact path", withExact);

Expected behavior

Calling search with exact: true should only return documents with terms that exactly matches.

Environment Info

@orama/orama 3.0.4

Affected areas

Search

Additional context

No response

zeroliu avatar Dec 28 '24 06:12 zeroliu

Anybody looking at this issue? Any pointer would be appreciated @micheleriva

logancyang avatar Jan 10 '25 21:01 logancyang

Hi @logancyang and @zeroliu, we are currently experiencing a temporary slowdown in managing this activity. We will keep you updated.

micheleriva avatar Jan 13 '25 08:01 micheleriva

I'll try to speed this up:

/bounty 150

micheleriva avatar Jan 13 '25 10:01 micheleriva

πŸ’Ž $150 bounty β€’ OramaSearch

Steps to solve:

  1. Start working: Comment /attempt #866 with your implementation plan
  2. Submit work: Create a pull request including /claim #866 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

❗ Important guidelines:

  • To claim a bounty, you need to provide a short demo video of your changes in your pull request
  • If anything is unclear, ask for clarification before starting as this will help avoid potential rework
  • Low quality AI PRs will not receive review and will be closed
  • Do not ask to be assigned unless you've contributed before

Thank you for contributing to oramasearch/orama!

Attempt Started (UTC) Solution Actions
🟒 @keremercin Oct 01, 2025, 05:29:51 AM #985 Reward
🟒 @melmathari Sep 04, 2025, 04:16:48 PM #968 Reward
🟒 @Erodri6z Feb 04, 2025, 11:22:24 PM WIP
🟒 @ram-amoncar Feb 13, 2025, 07:17:09 AM WIP
🟒 @akv2011 Jan 13, 2025, 10:14:37 AM WIP
🟒 @algora-pbc May 20, 2025, 03:01:38 PM WIP
🟒 @vachmara May 20, 2025, 03:01:36 PM #941 Reward
🟒 @luffy-orf May 24, 2025, 04:20:10 AM #942 Reward

algora-pbc avatar Jan 13 '25 10:01 algora-pbc

/attempt #866

akv2011 avatar Jan 13 '25 10:01 akv2011

/attempt #866

Erodri6z avatar Feb 04 '25 23:02 Erodri6z

@matijagaspar is this fixed with your last PR?

micheleriva avatar Feb 13 '25 17:02 micheleriva

I'm experiencing this issue with the latest version (3.1.1).

joybro avatar Mar 08 '25 08:03 joybro

I understand the problem. It happens because the adject match in search matching with "First" But not with "Note.md" And this is the behavior of "orama" as it tokenise the name when an space occours. Thats why you are getting the error.

@zeroliu Could you assign to me. I can fix it. /assign #866

Mobarak786 avatar Mar 19 '25 08:03 Mobarak786

Thanks for looking into it @Mobarak786 . I don't have the permission to assign the ticket though. Maybe a repo admin can help

zeroliu avatar Mar 20 '25 17:03 zeroliu

Hi @Mobarak786 , @zeroliu , thanks for your help! You don't need to get the issue assigned, just send a PR and if it gets merged, we will pay the bounty. Thanks again!

micheleriva avatar Mar 21 '25 07:03 micheleriva

Exact match

The exact property finds all the document with an exact match of the term property.

const searchResult = search(movieDB, {
  term: "Chris",
  properties: ["director"],
  exact: true,
});

We are now searching for all the documents that contain exactly the word Chris in the director property.

πŸ“Œ Without the exact property, for example, the term Christopher Nolan would be returned as well, as it contains the word Chris.

So in my opinion there is no bug in the issue. The issue is with the example input , the creator of the issue uses.

πŸ“issue shoud be closed. Don't need a PR

Mobarak786 avatar Mar 24 '25 12:03 Mobarak786

@micheleriva is this issue still open? if. then I will start working on it

Sambit003 avatar Mar 24 '25 15:03 Sambit003

@micheleriva I believe what @Mobarak786 pointed out is correct.

Can you advise if the output should only include if the document had "first.md" in the user's test case?

DecodersLord avatar Mar 31 '25 20:03 DecodersLord

@micheleriva Could you check with @Mobarak786 said, if its not correct then could you advise regarding the way it should work? I'm eager to work on this.

Omar8345 avatar Apr 13 '25 12:04 Omar8345

Hello @zeroliu,

I have introduced a PR #941 related to this topic and would greatly appreciate your feedback. Your insights would be incredibly valuable in refining the proposal further.

Thank you!

vachmara avatar May 22 '25 07:05 vachmara

Hey @zeroliu, if you can confirm that #941 works, I'd be happy to merge and release.

micheleriva avatar May 22 '25 23:05 micheleriva

/attempt #866

luffy-orf avatar May 24 '25 04:05 luffy-orf

Hi @zeroliu, I’ve put together an online sandbox with my implementation here. Does this match what you were looking for? Let me know if you need any changes or have feedback!

vachmara avatar Jun 06 '25 16:06 vachmara

Thanks for the fix @vachmara . I verified the change in the sandbox, and it resolves my issue. @micheleriva, let me know when you are okay to merge it. Thanks all!

zeroliu avatar Jun 07 '25 05:06 zeroliu

Hello @zeroliu can I still work on this issue??

naaa760 avatar Jul 09 '25 03:07 naaa760

Hi @naaa760, @vachmara already provides a solution waiting to be merged. I don't think an alternative solution is needed at this point.

zeroliu avatar Jul 09 '25 04:07 zeroliu

Okay thankyou for letting me know!

naaa760 avatar Jul 09 '25 06:07 naaa760

/attempt #866

melmathari avatar Sep 04 '25 16:09 melmathari

Any acceptable solutions to be merged and released? @micheleriva

logancyang avatar Sep 24 '25 08:09 logancyang

@logancyang I have a PR open for this but haven’t received any feedback yet. Totally understand if @micheleriva is busy with other responsibilities.

melmathari avatar Sep 24 '25 08:09 melmathari

/attempt #866

keremercin avatar Oct 01 '25 05:10 keremercin

PR sent #985

keremercin avatar Oct 01 '25 06:10 keremercin