Announcement

  •  » Requests
  •  » Tags/Keywords - need for range search

#1 2019-02-07 18:05:37

naponline
Member
2014-10-14
21

Tags/Keywords - need for range search

Hello,

With my Piwigo site I alway add keywords referring to years (from 1789 to 1816) ... so it is easy to get results like "show me photos with keyword ='1800'" but I would also appreciate to allow searches of the manner "show photos between '1800' AND '1805'".

I hope you get my apply - perhaps there's an extension I don't know to use; if not perhaps it is a valuable addition for the next releases?

Thank you ... kind regards from Berlin
Markus Stein

Piwigo version: 2.9.4
PHP version: 7.1.26
MySQL version: 5.5.60
Piwigo URL: http://uniformenportal.de

Offline

 

#2 2019-02-07 20:40:25

executive
Member
2017-08-16
1214

Re: Tags/Keywords - need for range search

I don't think this will be added. It's not a good way to do it because Piwigo treats tags as text. It doesn't understand what they mean.


Here is a better solution:
Install the Smart Albums plugin. Create smart albums. Add filters:

method 1: Add tag filters for each year you want to include: "1800", "1801", "1802" etc.

method 2: Change the add or creation date of photo to reflect the year that you want. Then use a date filter "after date x" and "before date y"

Last edited by executive (2019-02-07 20:42:04)

Offline

 

#3 2019-02-08 16:29:03

naponline
Member
2014-10-14
21

Re: Tags/Keywords - need for range search

Thanks for your answer - o.k. the change of text to searchable dates is not easy but a search of text tags would work if "1800" can be treated as less than "1801" in case of the character order.

Your advices are good, but I fear I should have asked earlier as I've more than 2,000 photos in my Piwigo-library.

Kind regards
Markus Stein

Offline

 

#4 2019-02-09 01:20:52

executive
Member
2017-08-16
1214

Re: Tags/Keywords - need for range search

naponline wrote:

a search of text tags would work if "1800" can be treated as less than "1801"

But it isn't treated that way. You cannot perform math on text strings without adding a lot of programming, and it's just not worth it. I have not seen ANY software that is able to do what you say.

It would be much easier to use a program to filter all images by a tag , and then batch change the dates.

Offline

 

#5 2019-03-05 17:01:47

Schmidtze
Member
2018-11-24
5

Re: Tags/Keywords - need for range search

executive wrote:

But it isn't treated that way. You cannot perform math on text strings without adding a lot of programming, and it's just not worth it. I have not seen ANY software that is able to do what you say.

??? Of course you can! ALL software I know for handling data can do this. In JavaScript it's possible to do something like

  let a = 'abc';
  let b = 'def';
  if (a < b) {
    alert(a + ' is lighter than ' + b);
  }

All programming languages I know (C, C++, Java, Pascal etc.) has got standard functions for comapring strings like this...

And Piwigo is using MySQL, which also can do this:

  SELECT * FROM `piwigo_tags` WHERE name >= '1800' AND name < '1900'

or

  SELECT * FROM `piwigo_tags` WHERE name BETWEEN '1800' AND '1900'


So only an additional input field would be nessecary in PiWigo. If this would make sense, I don't know. But you can't argue, that it wouldn't be possible easily ;-)

Best regards
Friedemann

Offline

 

#6 2019-03-06 02:43:08

executive
Member
2017-08-16
1214

Re: Tags/Keywords - need for range search

Is the code in your example simply comparing the sum of ASCII values?
If so, then the result would be that 1899 is greater than 1900.

Offline

 

#7 2019-03-06 07:51:11

Schmidtze
Member
2018-11-24
5

Re: Tags/Keywords - need for range search

executive wrote:

Is the code in your example simply comparing the sum of ASCII values?
If so, then the result would be that 1899 is greater than 1900.

No, of course not. A string comparison will be done by comparing each character one by another by their ordinal value, which is the ASCII value. So "0" is greater than " " (space), "5" is greater than "0", "a" is greater than "5", "k" is greater than "a" etc.

That's how sorting of strings is done, which you can see in ALL software you know, I assume ;-)

But also "3" is greater than "10". That's a problem when you want to sort strings which are numbered at the beginning, for example track titles like "10. Sun King" and "5. Octopus’s Garden". Then normally they will be sorted wrong, because "5" is greater than "10". Windows 10 does it correctly in the Explorer, but there are some other file commanders which do it wrong. The solution is to name it like "05. Octopus’s Garden", then the comparison will be ok, because "10" is greater than "05"...

As you already know sorted lists of strings, also from Piwigo, it wouldn't be a problem to do something like

  SELECT * FROM `piwigo_tags` WHERE name >= '1800'

Then the result will be all tags which names ares sorted behind the "1800" (and in this case also the "1800" itself). And I think you would expect a list of strings like "Something", "1901", "1789", "1850" to be sorted as "1789", "1850", "1901", "Something", don't you?

You are not a programmer, are you? Perhaps it's better not to answer technical requests regarding their effort, because sometimes it's easier than a non programmer thinks - but sometimes it's also more difficult...

In this case, the request of naponline, an additional input field would be necessary for the "until" value. If it's empty, the selection has to be done like it is already. If it's filled, for example with "1900", than a "BETWEEN" selection could be done. That's all. Also helpful for showing all keywords beginning with "A" or "E" until "K" or whatever...


Best regards
Friedemann

Offline

 

#8 2019-03-06 09:07:13

executive
Member
2017-08-16
1214

Re: Tags/Keywords - need for range search

I know a bit of programming (not SQL), but I've never seen the '<' '>' operators used directly on text strings before. Thank you for that bit of information.

Anyway, there's no need to get preachy to me. naponline is not trying to learn programming and I'm not trying to teach him. This was a feature request to the devs, and my skills are completely inconsequential to this topic.

I still think the best way to do this would be to use the date fields themselves.

Offline

 

#9 2019-03-06 10:43:22

Schmidtze
Member
2018-11-24
5

Re: Tags/Keywords - need for range search

executive wrote:

I know a bit of programming (not SQL), but I've never seen the '<' '>' operators used directly on text strings before.

I'm not sure, but you will see this only in JavaScript and SQL, not for example in C, C++ and Java (in C++ it's possible to overload the operators, so it's possible there maybe too). In these languages there exists a function usually for comparing strings, which return 0 (for equality), a negative value if the first string is less than the second and a positive value if the first string is greater than the second string. For example in Delphi you have something like

  x := CompareStr('1900', '1800')

which results in a positive result, for example 1. This value will be used then in sorting algorithms or whatever.


executive wrote:

Anyway, there's no need to get preachy to me.

oh, why do you think I do? Because of my explanations? Of course I didn't/don't want to be "preachy"!!! I didn't know the word and had to look it up :-D I only wanted to explain... Or do you say it because of my comment "Perhaps it's better not to answer technical requests"??? Yes, you are right, that's maybe preachy or in fact it doesn't sound very friendly. So excuse me please, I didn't want to sound preachy nor unfriendly in any way. My English is not the best, so it's maybe because of this... So again, excuse me so much for it! I really appreciate your work here in the forum a lot!!!

executive wrote:

I still think the best way to do this would be to use the date fields themselves.

yes, maybe you are right! And naponline said, that he already have about 2.000 images. @napoline: That's not much, there are a lot of programs with which you can set the taken date time values in batch mode, I think. Simply set it to "1800-01-01 00:00:00" for an image from 1800...

Best regards
Friedemann

Offline

 
  •  » Requests
  •  » Tags/Keywords - need for range search

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact