• Welcome to the Lightroom Queen Forums! We're a friendly bunch, so please feel free to register and join in the conversation. If you're not familiar with forums, you'll find step by step instructions on how to post your first thread under Help at the bottom of the page. You're also welcome to download our free Lightroom Quick Start eBooks and explore our other FAQ resources.
  • Stop struggling with Lightroom! There's no need to spend hours hunting for the answers to your Lightroom Classic questions. All the information you need is in Adobe Lightroom Classic - The Missing FAQ!

    To help you get started, there's a series of easy tutorials to guide you through a simple workflow. As you grow in confidence, the book switches to a conversational FAQ format, so you can quickly find answers to advanced questions. And better still, the eBooks are updated for every release, so it's always up to date.

Library module Searching combined keywords

Joined
Nov 4, 2011
Messages
62
Lightroom Experience
Advanced
Lightroom Version
Classic
Lightroom Version
9.4
Operating System
  1. Windows 10
Occasionally, I have a need to search (among all or within selected) for photos with criteria based on 'combinations' of keywords.

Assume that K1 and K2 are two different and used keywords.

How do I find photos having:

- K1 AND K2?
- K1 XOR K2?
- K1 AND (NOT K2)?
- (NOT K1) AND (NOT K2)?

Found photos are allowed to have any other keyword.

Can a situation where collection C1 contains photos having K1 and C2 contains K2-photos, facilitate my searching efforts? If 'yes', then how?
 
Joined
Jun 20, 2009
Messages
17,393
Location
Houston, TX USA
Lightroom Experience
Power User
Lightroom Version
Cloud Service
There are several ways to approach this. My preferences would be to create a smart collection although almost anything in a Smart Collection can be derived from a filterbar filter
- K1 AND K2?
{keywords}{contains}{K1 K2}. (The space between phrases is read as "AND")
- K1 XOR K2?
{Any of the following are True}
{keywords}{contains}{K1}.
{keywords}{contains}{K2}.
- K1 AND (NOT K2)?
{keywords}{contains}{K1 !K2}. (The space between phrases is read as "AND" and the ! is interpreted as NOT)
- (NOT K1) AND (NOT K2)?
{keywords}{contains}{!K1 !K2}. (The space between phrases is read as "AND" and the ! is interpreted as NOT)

There are a multitude of ways to construct multiple criteria the achieve the results desired.

Also note that Keywords is a phrase consisting of one or more words separated by a space. space between words in the phrases is always read as "AND"
 
Joined
Nov 4, 2011
Messages
62
Lightroom Experience
Advanced
Lightroom Version
Classic
Many thanks for good solutions, but ...

- K1 XOR K2?
{Any of the following are True}
{keywords}{contains}{K1}.
{keywords}{contains}{K2}.

It looks like photos in such a smart collection will contain K1 OR K2. I am looking for K1 "Exclusive or" K2. Found photos should have K1 or K2, not both.
 
Joined
Jun 20, 2009
Messages
17,393
Location
Houston, TX USA
Lightroom Experience
Power User
Lightroom Version
Cloud Service
Many thanks for good solutions, but ...

- K1 XOR K2?
{Any of the following are True}
{keywords}{contains}{K1}.
{keywords}{contains}{K2}.

It looks like photos in such a smart collection will contain K1 OR K2. I am looking for K1 "Exclusive or" K2. Found photos should have K1 or K2, not both.
For that case:

{Any of the following are True}
{keywords}{contains}{K1 !K2}.
{keywords}{contains}{K2 !K1}.
 
Joined
Apr 3, 2012
Messages
741
Lightroom Experience
Advanced
Lightroom Version
Classic
Also note that Keywords is a phrase consisting of one or more words separated by a space. space between words in the phrases is always read as "AND"
The keyword operators are more complicated, and a space is not always interpreted as a logical AND:

"Keywords contain word1 word2" matches photos whose keywords contain the string "word1" or the string "word2", anywhere within the keywords. For example, "Keywords contain man boy" would match a photo containing the single keyword "policeman".​
"Keywords contain all word1 word2" matches photos whose keywords contain the string "word1" and the string "word1" anywhere within the keywords. For example, "Keywords contain all man boy" would match a photo containing the two keywords "policeman" and "boyfriend", but it wouldn't match a photo containing the single keyword "policeman".​
"Keywords contains words word1 word2" matches photos whose keywords contain the strings "word1" and the string "word2" as punctuation-separated "words" in the photos. For example, "Keywords contains words man boy" would match a photo with keywords "burning man" and "boy toy", but not a photo with just the keyword "man", and not a photo with the keywords "man" and "boyfriend".​
"Keywords don't contain word1 word2" is logically equivalent to NOT (Keywords contain word1 word2), which is equivalent to (NOT Keywords contain word1) AND (NOT Keywords contain word2). That is, it matches photos whose keywords contain neither "word1" nor "word2" as strings. For example, "Keywords don't contain man boy" would exclude a photo with the single keyword "policeman".​
To make things more complicated, it's impossible using the Keywords criterion to search precisely for a keyword containing multiple words. For example, "Keywords contains words John Ellis" would match a photo with keywords "St. John" and "Barbara Ellis". This is because the Keywords criterion treats the keywords as a single field containing all the photo's keywords.

You can often improve the precision of your search using ! to exclude unwanted words, e.g. using "! St" and "! Barbara". But good luck if you want to search for the two names "John Ellis" and "Barbara Jones" (and exclude "Barbara Ellis").

In general, LR's search wasn't designed to handle keywords containing multiple words.

The only way to do exact keyword search with LR's built-in features is by using the Keyword column of the Library Filter bar's Metadata browser.

Untitled.png


This matches photos with ("John Rolfe Ellis" OR "Peter Charles Ellis") AND ("Barbara Gleason" OR "Edna Green").

But the Keyword column is very fussy to use, especially if you have hundreds or thousands of keywords, with its tiny scroll bar and no ability to search within a column for the desired keyword.

If you want precise, quick search of multi-word keywords, you'll need a plugin, e.g. the Filter By Keyword command of the Any Tag plugin or the Any Filter plugin.
 
Top