Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: 1.5.6 Exact Keyword search phrases  (Read 8870 times)

0 Members and 1 Guest are viewing this topic.

Big_T

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
1.5.6 Exact Keyword search phrases
« on: July 15, 2010, 08:04:57 am »

Hello,

I have been searching the forums for some time try to get a solution to this problem.

If I have keywords for 3 separate images labeled:

#1 pure black
#2 pure white
#3 pure green

If I type "pure white" in the search box all 3 images come up because they all share the word "pure"

Is there a workaround or code I can add to only match exact search phrases when using multiple search keywords?

I have found these posts which seemed promising:

http://forum.coppermine-gallery.net/index.php/topic,34219.msg160066.html#msg160066

http://forum.coppermine-gallery.net/index.php/topic,30310.msg140285.html#msg140285



 but I believe they pertain only to 1.4 as when I alter the code on search.inc.php file located in the include folder, it seems to deactivate the search function all together?



Best regards,

Big_T



Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Logged

Big_T

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: 1.5.6 Exact Keyword search phrases
« Reply #2 on: July 15, 2010, 08:46:03 pm »

Board rules / Forum policies: Post Links

I'm not sure what difference it makes? The problem is described in original post.

Here is the link to my gallery in progress:

http://hd8y37tu8.mkoh.com/cpg15x/

Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4885
    • Windsurf.me
Re: 1.5.6 Exact Keyword search phrases
« Reply #3 on: July 15, 2010, 09:05:26 pm »

The search is working as expected for me. I selected AND in the box the the keywords pure green returned only 2 images.

http://hd8y37tu8.mkoh.com/cpg15x/thumbnails.php?search=pure+green&submit=search&album=search&title=on&newer_than=&caption=on&older_than=&keywords=on&type=AND

The search for pure white returned

http://hd8y37tu8.mkoh.com/cpg15x/thumbnails.php?search=pure+white&submit=search&album=search&title=on&newer_than=&caption=on&older_than=&keywords=on&type=AND

While some of the keyword in the image - http://hd8y37tu8.mkoh.com/cpg15x/displayimage.php?album=search&cat=0&pid=358#top_display_media are pure black you also have "black & white, white" etc and more uses of those keywords so what do you expect to happen?
Logged
It is a mistake to think you can solve any major problems just with potatoes.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: 1.5.6 Exact Keyword search phrases
« Reply #4 on: July 15, 2010, 09:12:47 pm »

I'm not sure what difference it makes?
Here's the difference:
The search is working as expected for me. I selected AND in the box the the keywords pure green returned only 2 images.
Logged

Big_T

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: 1.5.6 Exact Keyword search phrases
« Reply #5 on: July 15, 2010, 10:33:28 pm »

Here's the difference:



Ok let me rephrase and give an different example as the problem remains the same:

For most images of people I have the keyword either "Male" or "Female"  Well if you type in "male" you get all the females as well. 

One more example:

If you type in "pure white" you get all the "black and white" images.



My question remans the same: Is there a way to have the keywords match exactly? so if looking for "male" all them images tagged "female" will not show up in the search results?



Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: 1.5.6 Exact Keyword search phrases
« Reply #6 on: July 16, 2010, 05:39:17 am »

Has been asked/discussed many times before. Please use the search function of this board.
Logged

Big_T

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: 1.5.6 Exact Keyword search phrases
« Reply #7 on: July 16, 2010, 06:06:53 pm »

Has been asked/discussed many times before. Please use the search function of this board.


Please read my original post.

I found the results to be unsatisfactory that is why I am asking for 1.5.6.

I have used the search function and found the following results:

http://forum.coppermine-gallery.net/index.php/topic,34219.msg160066.html#msg160066

http://forum.coppermine-gallery.net/index.php/topic,30310.msg140285.html#msg140285


 I don't believe these solutions work in 1.5.6 unless I'm doing something wrong. All I did was replace the code in the "include/search.inc.php" file as instructed and reuploaded.


Do the fixes listed in the above post link work in 1.5.6? Possibly I'm doing something wrong, For me they do not work , when the fix code is replaced the entire search function does not yield any results at all.



Big_T


Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: 1.5.6 Exact Keyword search phrases
« Reply #8 on: July 19, 2010, 07:52:17 am »

Which of the two solutions did you try?
Logged

Big_T

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: 1.5.6 Exact Keyword search phrases
« Reply #9 on: July 19, 2010, 07:43:06 pm »

I tried both solutions,

Each solution seemed to disable the search function.



Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: 1.5.6 Exact Keyword search phrases
« Reply #10 on: July 20, 2010, 01:26:41 pm »

In include/search.inc.php, find
Code: [Select]
                        } elseif (strlen($string)) {
                                $words = explode(' ', $string);
                                foreach ($words as $word) {
                                        if (strlen($word)) {
                                                $word = addslashes($word);
                                                $fields = array();
                                                if ($superCage->get->keyExists('album_title') || $superCage->get->keyExists('category_title')) $albcat_terms[] = " LIKE '%$word%'";
                                                foreach ($search_params['params'] as $param => $value) {
                                                        if (in_array($param, $allowed)) $fields[] = "$param LIKE '%$word%'";
                                                }
                                                $sections[] = count($fields) ? '(' . implode(' OR ', $fields) . ')' : ''; 
                                        }
                                }
                        }
and replace with
Code: [Select]
                        } elseif (strlen($string)) {
                                $string = addslashes($string);
                                $fields = array();
                                if ($superCage->get->keyExists('album_title') || $superCage->get->keyExists('category_title')) $albcat_terms[] = " LIKE '%$word%'";
                                foreach ($search_params['params'] as $param => $value) {
                                        if (in_array($param, $allowed)) $fields[] = "$param LIKE '%$string%'";
                                }
                                $sections[] = count($fields) ? '(' . implode(' OR ', $fields) . ')' : ''; 
                        }
Logged

Big_T

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: 1.5.6 Exact Keyword search phrases
« Reply #11 on: July 21, 2010, 07:07:44 pm »

 That didn't seem to work? It seemed to not generate any thing and the search function seemed to hang up. (Different from previous code changes, not displaying bottom graphics)

Could it have to do with the amount of "}" ?

At first I copied exactly as stated above thinking the amount of "}" was off,

then I copied and pasted right from the top to the last line: $sections[] = count($fields) ? '(' . implode(' OR ', $fields) . ')' : ''; 

But still yielded the same response.


Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: 1.5.6 Exact Keyword search phrases
« Reply #12 on: July 21, 2010, 09:27:50 pm »

The code works for me as you want it to work. If it doesn't work for you, then you're doing something wrong. Sorry, but you give so little information that I lost the interest to help you.
Logged

Big_T

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: 1.5.6 Exact Keyword search phrases
« Reply #13 on: July 22, 2010, 12:57:57 am »

The code works for me as you want it to work. If it doesn't work for you, then you're doing something wrong. Sorry, but you give so little information that I lost the interest to help you.

Let me know know what information you need and I would be happy to provide. Sorry for being so vauge. What I did was replace the code as described and reupload the file to include folder.

Here is a link to what my search.inc.php file looks like as it sits now in the include folder : http://hd8y37tu8.mkoh.com/search.txt

Here is the result:  http://hd8y37tu8.mkoh.com/cpg15x/search.php


Type anything in the search box and you will see it does not work. I'm wondering what did I do wrong?


Thanks
Logged

Big_T

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: 1.5.6 Exact Keyword search phrases
« Reply #14 on: July 22, 2010, 02:17:40 am »

Disregard my previous post.  My bad I must have copied and pasted the code wrong sorry, fascinating how I could mess up such a simple task.

This code is useful in that it will match exact keywords, but, it will now not recognize keyword combinations. So if I have an image that is keyword tagged for "seamless" and "white"  (seamless,white). If I type "white seamless" in the search box. Nothing comes up.

Also still if I type "Male" all the "Female" tagged images still come up?

http://hd8y37tu8.mkoh.com/cpg15x/search.php


Tom
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: 1.5.6 Exact Keyword search phrases
« Reply #15 on: July 22, 2010, 08:51:27 am »

If you want to achieve what you described, you have to choose a character which tells Coppermine where a keyword starts and where it ends (= where they are separated in the user input).

Example: if you enter 'pure white', are these 2 keywords or just one? Coppermine can't know.

But if you specify that a semi-colon is the separator and you enter 'pure;white' then Coppermine can handle them as 2 keywords. This specification has to be set in the code!

It's not trivial, as you have to split the keywords and compare them separately (or with a regex). Maybe I find some spare time later to create that code.
Logged

Big_T

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: 1.5.6 Exact Keyword search phrases
« Reply #16 on: July 23, 2010, 06:40:31 am »

Ahhh, I think I understand what you mean.

I'll try to figure it out.

I appreciate your help on it so far.


T
Logged
Pages: [1]   Go Up
 

Page created in 0.027 seconds with 19 queries.