# Smart Gallery Query parameters



## thalesm (Jul 12, 2019)

Hi everyone,
I'm having a problem with making the right query that I want with LR.
I tried several ways but it looks that the "OR" operator does not have a place in LR
Let's say that I want to select in my catalog some images that have "Job=Type A" or "Job=Type B". 
The catalog has in the "Job field", 5 values ranging from "Type A" to "Type E".
I also tried the hidden "Alt" and click on plus symbol, but nothing makes gave the right answer.
This is what I want:
Get from the database:
All *Pick Flag*= flagged and
All *Label Colo*r=blue and
All *Family View 12* that contains only the word "Nadia" And
*Job* that contains "Type A"  *OR* Job that contains "Type B". ( don't select Job c,d,e)

Lr is very confusing in the way it handles the operators (AND, OR, NOT, =, and etc...). 
They tried to make it easier for people that don't have the right knowledge of a SQL database queries  for example:







The definition of what they meant by *contains* or *contains all *and some other terms that they use are not very clear and I couldn't find any documentation or a good explanation of what they meant by those terms in the selection.




At this point, I don't know if my query is possible in LR and would like to have some help on this and if possible if someone has a good explanation of those confusing operators that LR uses in the queries.

Thank you


----------



## johnbeardy (Jul 12, 2019)

Have you not tried pressing the Alt/Opt key when you add a parameter? This would allow you to nest the job criteria.

Yes, the smart collection is quirky and a bit confusing.


----------



## clee01l (Jul 12, 2019)

johnbeardy said:


> Yes, the smart collection is quirky and a bit confusing


The Criteria construction is built for an intended audience that has no knowledge of the Structured Query Language (SQL). It is not expected that these folks would have a significant need for a complex query.


----------



## johnbeardy (Jul 12, 2019)

Sure, but it's still  weird. That Alt/Opt trick should never have been hidden, for example, and how "Starts with" functions would fool most people.


----------



## thalesm (Jul 13, 2019)

Thanks for the comments so far.
The problem is also because Adobe doesn't provide a clear and full explanation of the terms used as selectors on those queries.
What is behind "contain all" or "contains words".
Let us say that the search criteria is to be "images of London" on a database that has "images of London streets", "images of London Tower", " images of London parks" in a field to be searched.
All entries contain the words "images of London" and I just want "images of London streets" OR "images of London parks" as a result of the query.
It's confusing if they don't specify what is behind the terms *contains all, contain words, contains* and etc.... Each line of the rule table is an "*AND*" or an "*OR*" for the final query?
Does anyone saw an official document from Adobe on those questions? I haven't!. Even the "!" (not) is not documented also. I found that it works by accident.
Answering to johnbeardy. Yes, I tried also the Alt/Opt key, but it does not provide me the correct intended search answer.
Answering to cleeo1I. More and more photographers are using LR for several reasons. For me the two main areas are:
1- simple raw treatments otherwise I'll use Photoshop.
2- organization of images (library module). By the way, even with a small database, it hangs a lot. The only solution is to restart LR, which I must do every 15 min. or so depending on the number of metadata that I change or update. With a database of 50K images that I have, it's almost impossible to work in the library module. Adobe says that it can handle large databases (100K or more) but this is not true if you expect to have a resonable response time over those updates of information. They must re-think/optimize the database/library module. This is a big issue in my opinion.
Thank everyone for the help so far, and let's hope for some more details on how to handle those reported problems.
Cheers


----------



## Califdan (Jul 13, 2019)

> Does anyone saw an official document from Adobe on those questions? I haven't!


In item 4 of How to find photos in a catalog in Lightroom Classic they define these terms as used in text filters

*Contains*
_Searches for the specified alphanumeric sequence(s), including partial words. For example, performing a Contains search for flo returns results that include the word flower. If multiple sequences are entered, Lightroom Classic finds photos that contain any of the individual sequences.

*Contains All*
Searches for text that contains all specified alphanumeric sequences. Say, for example, you have a folder of photos of a family gathering, and each photo is tagged with the names of the individuals in the shot. You could perform a Contains All search on Joh and Su to find all photos that contain both John and Susan. Simply enter a space between search terms.
*
Contains Words*
Searches for text that contains all specified alphanumeric sequences as whole words. To find photos with the keyword flower using a Contains Word search, for example, type flower.

*Doesn’t Contain*
Searches for text that does not contain any specified sequence.

*Starts With*
Searches for text that begins with the specified alphanumeric sequence.

*Ends With*
Searches for text that ends with the specified alphanumeric sequence._



> Even the "!" (not) is not documented



In item 5 of the same document you will find

_Note:
Add an exclamation point (!) before any word to exclude it from the results. Add a plus sign (+) before any word to apply the Starts With rule to that word. Add a plus sign (+) after any word to apply the Ends With rule to that word._

In the document on collections they mention in a note for smart collections that the operators are the same as for text filters.  What they don't mention is the use of the alt key (Option on Mac) to "indent" and thus allow an infinite mix of and and or operations

Here, for example, is one of my smart collections....






As you can see, they can be quite sophisticated.


----------



## thalesm (Jul 13, 2019)

Califdan said:


> In item 4 of How to find photos in a catalog in Lightroom Classic they define these terms as used in text filters
> 
> *Contains*
> _Searches for the specified alphanumeric sequence(s), including partial words. For example, performing a Contains search for flo returns results that include the word flower. If multiple sequences are entered, Lightroom Classic finds photos that contain any of the individual sequences.
> ...


Thanks for the information.


----------



## LouieSherwin (Jul 14, 2019)

But even given all this sophistication you still cannot search for any strings with embedded spaces. This makes it practically impossible to search for real world expressions like "San Diego" or "John Smith". 

Cletus I did read your response to my last post regarding this limitation (bug IMHO) and I understand that the default treatment of a space as a OR is valid. However, computer text searches since almost the beginning have allowed many methods escaping special characters imbedded in text and to not allow for that within the Lightroom text searching/matching is a significant oversite.

-louie


----------



## clee01l (Jul 14, 2019)

LouieSherwin said:


> But even given all this sophistication you still cannot search for any strings with embedded spaces. This makes it practically impossible to search for real world expressions like "San Diego" or "John Smith".
> 
> Cletus I did read your response to my last post regarding this limitation (bug IMHO) and I understand that the default treatment of a space as a OR is valid. However, computer text searches since almost the beginning have allowed many methods escaping special characters imbedded in text and to not allow for that within the Lightroom text searching/matching is a significant oversite.
> 
> -louie


Yes, agreed.  Adobe early on made a big mistake wrt the treatment of spaces in a query.  Making it right as they should will break a lot of existing Smart Collections.   It is my opinion that they should create a new query process as an option retaining the old query process as they have done with "Process Version"  Old queries would default to the old query process and new query editor would default to the new query process.


----------



## Califdan (Jul 14, 2019)

> But even given all this sophistication you still cannot search for any strings with embedded spaces. This makes it practically impossible to search for real world expressions like "San Diego" or "John Smith".
> 
> Cletus I did read your response to my last post regarding this limitation (bug IMHO) and I understand that the default treatment of a space as a OR is valid. However, computer text searches since almost the beginning have allowed many methods escaping special characters imbedded in text and to not allow for that within the Lightroom text searching/matching is a significant oversite.



Yep.  We've been complaining about that since version 1.  Using a space as a delimiter is fine but only if you then allow spaces in Quotes (e.g.  "San Diego") to be treated as a single string and not two strings).


----------



## Johan Elzenga (Jul 14, 2019)

True, but there is a useful workaround. Like I mentioned in another thread, you can effectively search for 'John Smith' by using 'Starts with John Smith'. If you have images that are still giving false positives because they contain 'John Smithson', then you can add 'Contains words John Smith', or you can add 'Ends with John Smith'. That will work fine in almost all situations.


----------



## Califdan (Jul 14, 2019)

Yes, that is a work around that can yield the desired results in most cases using Smart Collections.  A tad more difficult (impossible?) to do with the filter bar though.   

But, any way you slice it, it is a kludge to get around a poor design choice by Adobe to not allow quoted strings  (e.g.  "John Smith" in filter and Smart Collection text arguments.   It is not like putting search  strings in quotes (or other means to the same end)   is cutting edge technology.  Even when LR/1 came out,  this sort of thing was common in one form or another in almost every application that allowed searches for text strings.    It also seems that the SQLite database (utilized by the catalog) allows the use of quoted strings as literals in search arguments ("WHERE" clause)  so there really is no excuse for Adobe not allowing such syntax.


----------



## Johan Elzenga (Jul 14, 2019)

In the Filter bar there is a work around too, but that is even more kludgy: First, select the filter by Metadata and set one of the columns to Keywords. Then, in the top right of that column, click on the three stripes. Select 'Flat' rather than 'Hierarchical'. Now you can click on a keyword and that will select only images that have this exact keyword assigned to them, not images that have 'John' and 'Smith' in two different keywords and also not images that have a sub-keyword of 'John Smith' assigned, but not 'John Smith' itself.


----------



## thalesm (Jul 15, 2019)

Hi everyone,
This topic just got very interesting and very useful for people relying on smart queries and searches. All the threads are able to show that the is a real problem for Adobe to solve. Maybe they didn't realize what users will be doing once they got a database to organize their images. It looks to me that their main focus is in the develop module which will handle simple tasks on image treatment. Any serious one will have to fall back to Photoshop. On the other hand, the library module which handles all other things besides Develop, Map, Book, Slideshow, Print, and Web is almost the same since the last major database upgrade that made all old database to be updated. All the queries and search are done under this module in my understanding, and there is a lot of other problems there that are not addressed by Adobe in the latest updates. Like I mentioned in one of my last posts, the only way to make the database regain responsiveness is to restart LR, which is awkward. 
_*" By the way, even with a small database, it hangs a lot. The only solution is to restart LR, which I must do every 15 min. or so depending on the number of metadata that I change or update. With a database of 50K images that I have, it's almost impossible to work in the library module. Adobe says that it can handle large databases (100K or more) but this is not true if you expect to have a reasonable response time over those updates of information. They must re-think/optimize the database/library module. This is a big issue in my opinion."*_
Thank you again for every input on this thread and if anyone has other similar problem it would be nice to document it here. In this way, Adobe can be aware of the problem, and maybe move those database problems to a higher priority in the maintenance list of future updates.
Cheers


----------



## LouieSherwin (Jul 15, 2019)

@Johan Elzenga ,

Thanks for your idea for how to work around the problem. I did read that.

It is I believe so unnecessary when all that has to be done is allow for quoted strings as a search term. Standard string searching since the early 1970's. I know LUA supports this and I am sure the SQL does also. So why it is Lightroom doesn't is a mystery to me me

It is one of the first things I had trouble with when I started using Lightroom 3. Here is my problem report eight years ago.

filter_keywords_in_the_keyword_list_panel_does_not_match_imbedded_spaces_in_keywords

Maybe if we had 500 people start to complain Adobe  would listen. So tell all your friends and your friends friends....

-louie


----------



## thalesm (Jul 15, 2019)

LouieSherwin said:


> @Johan Elzenga ,
> 
> Thanks for your idea for how to work around the problem. I did read that.
> 
> ...


Does anyone know how to make this problem get to Adobe developers?


----------



## clee01l (Jul 15, 2019)

thalesm said:


> Does anyone know how to make this problem get to Adobe developers?


Bug Report / Feature Request  found in the menu at the top of this page.   The "500" complainers that Louie mentioned would need to comment or give the feature request enough hits to get Adobe's attention.   This is still no guarantee that Adobe will take action.  
It seems to me that Adobe has two teams of application developers.   One focuses on image enhancements which can be extended to Photoshop app as well.   The other (if it even exists) is responsible for Data Asset Management which handles the Library Module.


----------



## Roelof Moorlag (Jul 15, 2019)

thalesm said:


> Does anyone know how to make this problem get to Adobe developers?


Don't report a new request for this feature. Just vote for the one Louie posted: Lightroom: Filter Keywords in the Keyword List panel does not  match imbedded spaces in keywords | Photoshop Family Customer Community

I voted for it and the counter is now on 8. So only 482 to go!


----------



## thalesm (Jul 16, 2019)

Roelof Moorlag said:


> Don't report a new request for this feature. Just vote for the one Louie posted: Lightroom: Filter Keywords in the Keyword List panel does not  match imbedded spaces in keywords | Photoshop Family Customer Community
> 
> I voted for it and the counter is now on 8. So only 482 to go!


Up to 9 now with mine. Maybe in 2030, we'll get there!


----------



## LouieSherwin (Jul 16, 2019)

Here is another longer discussion of exactly this problem when building Smart Collections. 

lightroom_is_there_really_no_way_to_search_metadata_for_a_term_that_has_spaces_in_it

There are several topics that got merged together over time.  It seems to actually  recognized as a bug now but still not fixed.

-louie


----------

