Where can I find the file/function in the code where search is performed?

As many have pointed out (Search: Combine search terms rathen than add them up - #33 by sharcslife), BitWarden’s search feature is subpar. It defaults to a binary OR when it should default to a binary AND – like every other search interface/tool.

So I am looking to add a feature enhancement that switches the default search to a binary AND, and maybe an optional user configuration setting to specify the default search behavior.

I’m new to TS. I know JS and can find my way around TS code.

However, I cannot for the life of me find where the search code actually is. I assume somewhere in jslib/search.service.ts at 60878cd4ed9b1989860a918b62ce72529232560f · bitwarden/jslib · GitHub but I can’t find exactly where.

Feature/Fix name:

  • BitWarden Bit Search Fix

Feature/Fix Description

  • Switches the default search to a binary AND
  • Maybe a user configuration setting to specify the default search behavior

Clients / Repos Affected:

  • Web
  • Mobile
  • Desktop

Timeline to completion (estimate):

ETA: TBD

Actually, your interpretation of the basic search is not correct. It behaves like the search in all browsers, in Amazon searches, etc. - it returns all the AND hits first, and then when those are returned, it then displays the OR searches.

There are a couple of threads on this where people seem generally quite confused about this behaviour and there is some misinformation there, so be cautious about what you read from other users.

Here are the help docs which explain both the basic and advanced (full-text) search features of the different Bitwarden clients:

And here is a guide to the Lunr search engine, which is what is implemented in most clients for full-text searches:

https://lunrjs.com/guides/searching.html

Hi @imthenachoman, can you provide the use case where the current process doesn’t provide the information you are looking for? How many credentials are you looking for in this case?

If you are adding multiple terms to a search to isolate an item, it will show up at the top of the results, but let me know the scope of what you are trying to achieve.

If people are confused, then obviously the tool behavior is non-standard.

If you go to Google and search for something, does it do the same thing BW does? No. No other search tool shows AND results and then OR results. It shows AND results and if there are no more AND results, it doesn’t show anything – unless you explicitly state you want to use OR.

I hope you can realize how beyond confusing it is for folks when they search for “alpha bravo charlie” and are presented with results that don’t have all three.

It’s not that it doesn’t provide the information, it’s about how it provides it – the UI/UX.

If anyone searches for multiple terms in any search engine then they expect the results to include ALL terms. That is the standard default behavior in every single search engine you use.

So BW doing something non-standard is confusing and a bad UI/UX.

I love BW and want folks to use it but thats hard when basic UI/UX like this doesn’t work as users expect.

Respectfully @imthenachoman - this is not accurate. Please do a search using two terms on Google or Amazon and you will see that it returns matching AND queries first, followed by OR queries. Google even tells you when it is omitting one of the terms in an OR search. Countless search engines use this as a default search method. Seriously, have you ever seen Google or Amazon NOT return a full page of hits, regardless of whether all your search terms matched?

In fact, search engines like Google or storefront searches like Amazon even go a step further and add fuzzy-matched searches after they complete the AND and OR searches. If you don’t believe me, try searching for yourself.

And since you are not offering a Github contribution, but rather you are posing questions to the community, I have changed the category of your topic. If you get the answers you seek and want to pursue a github contribution, you are most welcome to start a new topic for that under the appropriate category. Cheers!

My mistake for using Google and Amazon as example – they aren’t a good comparison. Google and Amazon use AI/ML to extrapolate what the user might be searching for and include those results. If I search Amazon for “phone charger USB” – the results may not all have those 3 words in them but they will be logically near enough the query.

That is wholly different then searching your own list for things. For example, go into your phones address book and search – there is no logical OR in that search. Because it is unobvious to end user when searching their own inventory/list. Or search your emails – Gmail, Outlook, etc.

If I search BW for “bankofamerica nacho” it doesn’t make sense to get results for my Gmail login because nacho is in the username. The Gmail login wouldn’t be “logically near” my query.

If BW was using AI/ML to return what the user thinks it wants, that would be a different story. But it doesn’t and so it should return something that is more logically close to what the query is.

Got it. I was told to post this question in the other community which is why I posted it there. I fear most folks in this community won’t know the answer which is why I’m trying to post the question to a place that has developers who will know and can chime in. I’m just trying to help make BW better – but if that is not wanted then I understand.

We can definitely use this thread to better understand the use case you are presenting. For the example you provided above, can you clarify (with dummy data) what the specific item name would be, what you used as search terms and why it wouldn’t show up?

Let’s use a realistic use-case example for a fictious user:

  • user’s username for most online sites is somethingcrazy or some variation of it like [email protected]
  • user has multiple accounts with the same bank: reallycoolbank.com
    • one account with reallycoolbank.com is for themselves with the somethingcrazy user name
    • other accounts with reallycoolbank.com are for his children which he manages cause his kids are underage
  • as such, the user has multiple items in BW for reallycoolbank.com, each with a different user name
  • user might have a note for reallycoolbank.com, for their own account somethingcrazy, with information like the checking account #
    • the note might be called reallycoolbank somethingcrazy

Now, if the user searches for the term reallycoolbank somethingcrazy they expect to see the relevant items. They do not expect to see:

  • items for reallycoolbank for his kids
  • items for other sites where the login is somethingcrazy

Granted, the above items may be lower on the list but imagine the experience for the average user. They search for reallycoolbank somethingcrazy and see results that don’t logically fit/match. They aren’t going to conclude it’s showing results cause of logical OR. They are going to say the tool/search is broken – because the results are unexpected behavior.

Here is a screenshot of my results. I redacted best I could but labeled everything to get the point across.

  • I searched for {short name of my bank} {login user name}
  • The first 5 results are for other websites with the same {login user name}
  • The 6th result is valid because it has both {short name of my bank} and {login user name}
  • The 7th result is like the first 5
  • The 8th result is a note and is valid because it has both {short name of my bank} and {login user name}
  • The rest of the results are for the same bank but don’t have {login user name} in the notes

And notice the scrollbars. I’ve got hundreds of more results because I use {login user name} on so many sites. Why am I seeing those results when its very obvious I’m looking for results related to my bank? I don’t need to see my Twitter item when searching for my bank.

Now, imagine you’re an average user, you make a search like I did, and get results like that. You’re more than likely to think the search is broken, will get frustrated, and decide not to use the tool.

I love BitWarden because it is OpenSource and you can self-host which makes the inner cybersecurity architect in me happy. UI/UX is my passion. And that is why I am raising this feedback.

I was looking through Luna’s documentation. Even if Luna doesn’t have a way to set default behavior to logical AND, it would be trivial for the code to restructure/reformat the query to include the necessary Luna modifiers.

I just can’t, for the life of me, find where in the code the actual query is passed to the luna object.

By the way, I’d be happy to share my vault items extract. I could/would:

  1. export my vault as JSON
  2. search/replace all sensitive details in a uniform way
    • so if an item is labeled “ABC”, I’d change it to “DEF”
  3. share the file for someone else to import

In theory, if I do the above, and someone imports altered vault and searches for DEF user then they’ll see the same mess I see.