CLI - Query using multiple search terms? (boolean AND)

I know how to use the CLI to search for a single term e.g.

bw list items --search msft

but it seems there is no way to enter >1 keyword. E.g.

bw list items --search msft acme

fails to return any results. I also tried some variations (doesn’t work either)

bw list items --search msft,acme
bw list items --search "msft acme"

This is maybe ok for small vaults with just a few dozen passwords, but I have 650 items in mine. Is there any plan to allow boolean AND joined search?

(reference from https://github.com/bitwarden/cli/issues/163)

I don’t know if this will be helpful but I found this link in https://help.bitwarden.com
https://lunrjs.com/guides/searching.html

Strange that this request has been made such a long time ago and it is still not implemented. I sent an email to [email protected] asking for the same thing:

"It would be ideal when using the search function that it uses AND rather than OR so we can narrow down searches rather than add objects when searching. "

as I am new to Bitwarden having used a few other password managers but this is very a basic function so would’ve assumed it should be a top priority to get done properly.

They (from hello) replied to me only to say to raise it in the community portal

@MamunAhmed thank you for resurfacing this. Please upvote this if you can, I’m afraid nobody will pay much attention to it unless it gets a few votes. (also @vachan)

Copying @mgibson since he is the CLI guru these days :slight_smile:

Thanks @luckman212 - I have added a vote for this.
it is strange that this wasn’t an already thought of function.
It makes little sense to increase the number of entries whilst doing a search using OR

I am also going to start another request: add search function to include passwords as there are many occasions where you would know the partially pw but not the full pw so to be able to search the pw field just natural evolution. Please upvote that when you get a chance as I dont think that is there either.

1 Like

Try a boolean AND search like this:

bw list items --search msft --search acme

Note that the CLI documentation states that combining multiple filters performs a logical AND operation, but it works for search terms also.

@dh024 Nope. That does an OR search.

Worked for me. Again, note the double --search terms.

Here is some code and query results to demonstrate - I created three entries, all for the site “domain.com” and three login usernames {LoginUser1, LoginUser2, LoginUser3}. Each item in the vault was labelled Alpha, Beta, and Gamma respectively:

(base) dh024:~$bw list items --search domain.com #return all three entries
? Master password: [hidden]
[{"object":"item","id":"ad865b54-4e74-4bab-911c-ad790142d7c2","organizationId":null,"folderId":null,"type":1,"name":"Alpha","notes":null,"favorite":false,"login":{"uris":[{"match":null,"uri":"domain.com"}],"username":"LoginUser1","password":"7%ZNDQru$rQikcS","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2021-08-03T20:08:05.373Z"},{"object":"item","id":"a2a20aa2-c26a-4b1f-9748-ad79014308b6","organizationId":null,"folderId":null,"type":1,"name":"Beta","notes":null,"favorite":false,"login":{"uris":[{"match":null,"uri":"domain.com"}],"username":"LoginUser2","password":"roVk6Sz!$onH#t4","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2021-08-03T20:08:16.516Z"},{"object":"item","id":"5fa78701-d6b5-471e-8b1b-ad79014347a5","organizationId":null,"folderId":null,"type":1,"name":"Gamma","notes":null,"favorite":false,"login":{"uris":[{"match":null,"uri":"domain.com"}],"username":"LoginUser3","password":"@6Ab%C01!5w%0Yj","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2021-08-03T20:09:06.636Z"}]

(base) dh024:~$bw list items --search LoginUser1 #return just one match
? Master password: [hidden]
[{"object":"item","id":"ad865b54-4e74-4bab-911c-ad790142d7c2","organizationId":null,"folderId":null,"type":1,"name":"Alpha","notes":null,"favorite":false,"login":{"uris":[{"match":null,"uri":"domain.com"}],"username":"LoginUser1","password":"7%ZNDQru$rQikcS","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2021-08-03T20:08:05.373Z"}]

(base) dh024:~$bw list items --search domain.com LoginUser1 #defaults to logical OR search; 3 matches
? Master password: [hidden]
[{"object":"item","id":"ad865b54-4e74-4bab-911c-ad790142d7c2","organizationId":null,"folderId":null,"type":1,"name":"Alpha","notes":null,"favorite":false,"login":{"uris":[{"match":null,"uri":"domain.com"}],"username":"LoginUser1","password":"7%ZNDQru$rQikcS","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2021-08-03T20:08:05.373Z"},{"object":"item","id":"a2a20aa2-c26a-4b1f-9748-ad79014308b6","organizationId":null,"folderId":null,"type":1,"name":"Beta","notes":null,"favorite":false,"login":{"uris":[{"match":null,"uri":"domain.com"}],"username":"LoginUser2","password":"roVk6Sz!$onH#t4","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2021-08-03T20:08:16.516Z"},{"object":"item","id":"5fa78701-d6b5-471e-8b1b-ad79014347a5","organizationId":null,"folderId":null,"type":1,"name":"Gamma","notes":null,"favorite":false,"login":{"uris":[{"match":null,"uri":"domain.com"}],"username":"LoginUser3","password":"@6Ab%C01!5w%0Yj","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2021-08-03T20:09:06.636Z"}]

(base) dh024:~$bw list items --search domain.com --search LoginUser1 #logical AND search; only 1 match
? Master password: [hidden]
[{"object":"item","id":"ad865b54-4e74-4bab-911c-ad790142d7c2","organizationId":null,"folderId":null,"type":1,"name":"Alpha","notes":null,"favorite":false,"login":{"uris":[{"match":null,"uri":"domain.com"}],"username":"LoginUser1","password":"7%ZNDQru$rQikcS","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2021-08-03T20:08:05.373Z"}]

(base) dh024:~$bw list items --search domain.com --search Beta #another logical AND search; 1 match
? Master password: [hidden]
[{"object":"item","id":"a2a20aa2-c26a-4b1f-9748-ad79014308b6","organizationId":null,"folderId":null,"type":1,"name":"Beta","notes":null,"favorite":false,"login":{"uris":[{"match":null,"uri":"domain.com"}],"username":"LoginUser2","password":"roVk6Sz!$onH#t4","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2021-08-03T20:08:16.516Z"}]

(base) dh024:~$bw list items --search LoginUser --search Gamma #another logical AND; 1 match
? Master password: [hidden]
[{"object":"item","id":"5fa78701-d6b5-471e-8b1b-ad79014347a5","organizationId":null,"folderId":null,"type":1,"name":"Gamma","notes":null,"favorite":false,"login":{"uris":[{"match":null,"uri":"domain.com"}],"username":"LoginUser3","password":"@6Ab%C01!5w%0Yj","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2021-08-03T20:09:06.636Z"}]

Nice test but, no it’s just wrong.

bw just completely ignores the first --search parameter when you pass more than 1.

Try this (should be a logical AND:

bw list items --search asdfhaskfaslfhaslkgjhslgkjshdflgsjdfhlgskdfj --search LoginUser1

Also 1 match? :wink:

Ah shoot - you are correct. Sorry man - thought I had it there for a bit. :cry:

Strange that it will allow multiple filters in a search query, but not multiple search terms.

voted