Skip to content

Search with exact: true doesn't work as intended #866

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

Open
zeroliu opened this issue Dec 28, 2024 · 19 comments · May be fixed by #941
Open

Search with exact: true doesn't work as intended #866

zeroliu opened this issue Dec 28, 2024 · 19 comments · May be fixed by #941

Comments

@zeroliu
Copy link

zeroliu commented Dec 28, 2024

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

@logancyang
Copy link

logancyang commented Jan 10, 2025

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

@micheleriva
Copy link
Member

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

@micheleriva
Copy link
Member

I'll try to speed this up:

/bounty 150

@algora-pbc
Copy link

algora-pbc commented Jan 13, 2025

💎 $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
🟢 @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

@akv2011
Copy link

akv2011 commented Jan 13, 2025

/attempt #866

2 similar comments
@Erodri6z
Copy link

Erodri6z commented Feb 4, 2025

/attempt #866

@ram-amoncar
Copy link

/attempt #866

@micheleriva
Copy link
Member

@matijagaspar is this fixed with your last PR?

@joybro
Copy link

joybro commented Mar 8, 2025

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

@Mobarak786
Copy link

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

@zeroliu
Copy link
Author

zeroliu commented Mar 20, 2025

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

@micheleriva
Copy link
Member

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!

@Mobarak786
Copy link

Mobarak786 commented Mar 24, 2025

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

@Sambit003
Copy link

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

@DecodersLord
Copy link

@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?

@Omar8345
Copy link

@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.

@vachmara vachmara linked a pull request May 20, 2025 that will close this issue
9 tasks
@vachmara
Copy link

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!

@micheleriva
Copy link
Member

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

@luffy-orf
Copy link

/attempt #866

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 a pull request may close this issue.