4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2018, 11:32:22 PM

Login with username, password and session length
Search:     Advanced search
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Releases & Support)
| | |-+  Tutorials (Moderators: mawenzi, Rembrandt)
| | | |-+  [Tutorial] Making additional field searchable
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 3 4 5 » »» Print
This topic has not yet been rated!
Author Topic: [Tutorial] Making additional field searchable  (Read 141994 times)
Ofuuzo
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 0
-Receive: 0


View Profile
« on: August 06, 2002, 05:21:37 PM »

- first only a englisch version ...
- eine deutsche Version kommt bald ... oder später ... Wink ... zwischenzeitlich nutze diese Deutsche-Google-Übersetzung ...



I have added a field to the database to show not only the keywords, description, date ... . How can I make it searchable just like keywords, and description fields?

Thanks.

- Ofuuzo
« Last Edit: July 03, 2008, 01:12:26 AM by mawenzi » Logged
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 27


View Profile WWW
« Reply #1 on: August 06, 2002, 05:43:40 PM »

In this example, i presuppose that you have added a new field called image_photographer.


1. Create a new column in the table 4images_wordmatch called photographer_match
1
ALTER TABLE 4images_wordmatch ADD photographer_match TINYINT(1) DEFAULT '0' NOT NULL;


2.  Open includes/search_utils.php and find this part
1
2
3
4
5
$search_match_fields = array(
  "image_name" => "name_match",
  "image_description" => "desc_match",
  "image_keywords" => "keys_match"
);
add a new line to the array:
1
2
3
4
5
6
$search_match_fields = array(
  "image_name" => "name_match",
  "image_description" => "desc_match",
  "image_keywords" => "keys_match",
  "image_photographer" => "photographer_match"
);
Note the comma added behind the third line!


3. Open main.php in your lang folders and add a new line:
1
$lang['image_photographer_only'] = "Only Photographer";
Do this for all your languages!


4. Open the template search_form.html and add this:
1
<input type="radio" name="search_fields" value="image_photographer" /> {lang_image_photographer_only}


5. Rebuild the search index.
You can use the plugin from here.

Greets Jan
« Last Edit: March 16, 2005, 12:36:49 AM by V@no » Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
Ofuuzo
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #2 on: August 07, 2002, 12:19:16 PM »

That is great great great!!!,

Thank you very very much.

- Ofuuzo
Logged
Dmitro
Jr. Member
**
Offline Offline

Posts: 59

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #3 on: September 01, 2002, 01:08:19 PM »

Jan,

I have done all what you wrote above to make one of the fields searcheable. All should be fine, but, I have a misterious problem with some of my keywords:

Short keywords such as 16, 17, 18 do not return any records, while other keywords (longer numbers, such as 1666 and words such as violin, braccio etc ) make the job without any trouble.

What is the problem?

Thanks, indeed.

Dmitry
Logged

Regards,
Dmitry
____________________
www.violadabraccio.com
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 27


View Profile WWW
« Reply #4 on: September 01, 2002, 01:36:26 PM »

If you use version 1.7 you can define the min and max searchword length in "includes/constants.php".

1
2
define('MIN_SEARCH_KEYWORD_LENGTH', 3);
define('MAX_SEARCH_KEYWORD_LENGTH', 25);

After changing that, please rebuild your searchindex.

Greets Jan
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
Dmitro
Jr. Member
**
Offline Offline

Posts: 59

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #5 on: September 01, 2002, 01:43:38 PM »

Dear Jan,
Thanks a lot for your quick reply!
I am not yet using 1.7  - I am still checking how much work I have to do in order to upgrade.
Dmitry
Logged

Regards,
Dmitry
____________________
www.violadabraccio.com
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 27


View Profile WWW
« Reply #6 on: September 01, 2002, 01:52:29 PM »

Search for
1
if ($word != "" && strlen($word) > 2 && strlen($word) < 26 && !in_array($word, $stopword_list)) {

in "includes/search_utils.php" and
1
elseif ($split_words[$i] != "" && strlen($split_words[$i]) > 2 && strlen($split_words[$i]) < 26 && !in_array($split_words[$i], $stopword_list)) {

in "search.php" and change "2" to "1".

Jan
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
Dmitro
Jr. Member
**
Offline Offline

Posts: 59

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #7 on: September 01, 2002, 02:44:47 PM »

Jan, you are a magician.
Thanks. Dmitry Very Happy
Logged

Regards,
Dmitry
____________________
www.violadabraccio.com
k4nth
Newbie
*
Offline Offline

Posts: 28

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #8 on: January 28, 2003, 11:06:34 AM »

is it possible to include Categories names in search?
Logged
Jan
Administrator
4images Guru
*****
Offline Offline

Posts: 5024

Thank You
-Given: 0
-Receive: 27


View Profile WWW
« Reply #9 on: January 28, 2003, 03:32:30 PM »

No.

Jan
Logged

Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search
bernd
Full Member
***
Offline Offline

Posts: 214

Thank You
-Given: 0
-Receive: 1


View Profile
« Reply #10 on: March 22, 2003, 09:42:17 PM »

to be able to use it just like the keywords? I did the MODs so I have the photographer being shown below the image and I can search for this via the extended search but I'd like my users to be able to just click the photographer's name and they are then shown all pictures taken by this guy.

I tried to find how/where it is done for the keywords but I struggled ...

Thanks in advance!
Bernd
Logged
Psy
Pre-Newbie

Offline Offline

Posts: 5

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #11 on: March 28, 2003, 01:40:25 PM »

I'm having problems with making these fields searchable

I used the Mod to add extra fields ( 7 extra fields in total ) which worked fine...all the new fields dumped into the db fine and displayed fine.

Next, I followed this Mod to make these new fields searchable, and ran the rebuild search index tool,
witch gave me this error:

1
2
3
4
5
6
7
8
9
10
11
12
Processing image qqqqq, ID 9 ... OK
Processing image can, ID 10 ...
DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match, edibility_match, habitat_match, range_match, season_match, sporecolor_match, mushroomshape_match, lookalikes_match) VALUES (10, 7, 0, 1, 1, 0), (10, 10, 0, 0, 1, 0)
Column count doesn't match value count at row 1
OK
Processing image asasas, ID 11 ...
DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match, edibility_match, habitat_match, range_match, season_match, sporecolor_match, mushroomshape_match, lookalikes_match) VALUES (11, 12, 0, 0, 0, 0), (11, 13, 0, 0, 0, 0), (11, 14, 0, 0, 0, 0), (11, 15, 0, 0, 0, 0)
Column count doesn't match value count at row 1
OK


Search index rebuilt!





I them tried search my new fields, and found that I can search the first extra field I added, get a error when I try to search the rest of the new fields:
1
2
DB Error: Bad SQL Query: SELECT m.image_id FROM 4images_wordlist w, 4images_wordmatch m WHERE w.word_text LIKE 'rust' AND m.word_id = w.word_id AND m.sporecolor_match = 1
Unknown column 'm.sporecolor_match' in 'where clause'



I them tried to upload a new image, and got this error:
1
2
DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (image_id, word_id, name_match, desc_match, keys_match, edibility_match, habitat_match, range_match, season_match, sporecolor_match, mushroomshape_match, lookalikes_match) VALUES (12, 5, 0, 0, 0, 1), (12, 12, 0, 0, 0, 0), (12, 13, 0, 0, 0, 0), (12, 14, 0, 0, 0, 0), (12, 15, 0, 0, 0, 0)
Column count doesn't match value count at row 1



Can anyone tell me what I'm doing wrong? I understand that this error comes from adding different amount
of values in than there are columns, but I can't see where my error is....any ideas????
    Quote  [Expand]
    [/list:u]
    Logged
    Chris
    4images Moderator
    4images Guru
    *****
    Offline Offline

    Posts: 4487

    Thank You
    -Given: 0
    -Receive: 31

    Did u ever stop to think and then forget to start?


    View Profile
    « Reply #12 on: March 28, 2003, 02:44:53 PM »

    "Column count doesn't match value count at row 1"

    It looks to me like you have a mismatch in the number of fields you added to includes/db_field_definitions.php and the number of new database columns you created.  Recheck these.  Either that or you have a mismatch of the types.  IE:  You added a character field and an integer field in the php file but added an integer and then character column in the database table.
    Logged

    Psy
    Pre-Newbie

    Offline Offline

    Posts: 5

    Thank You
    -Given: 0
    -Receive: 0


    View Profile
    « Reply #13 on: March 28, 2003, 10:06:40 PM »

    Chris - thanks for the quick reply

    I've checked everything over 100 time and I still can't see anything wrong. What really gets me is that the first search field I added still works fine, but the rest don't.  Mad  Mad  Mad  Mad  Mad  Mad
    Anyone have any other ideas???????? Plaese Crying or Very sad
    Logged
    V@no
    If you don't tell me what to do, I won't tell you where you should go :)
    Administrator
    4images Guru
    *****
    Offline Offline

    Posts: 17849

    Thank You
    -Given: 47
    -Receive: 565

    mmm PHP...


    View Profile WWW
    « Reply #14 on: March 28, 2003, 11:26:56 PM »

    I didnt follow the discussion here Confused but, just a thought:
    Quote  [Expand]
    DB Error: Bad SQL Query: REPLACE INTO 4images_wordmatch (1 image_id, 2 word_id, 3 name_match, 4 desc_match, 5 keys_match, 6 edibility_match, 7 habitat_match, 8 range_match, 9 season_match, 10 sporecolor_match, 11 mushroomshape_match, 12 lookalikes_match) VALUES 1 (12, 5, 0, 0, 0, 1), 2 (12, 12, 0, 0, 0, 0), 3 (12, 13, 0, 0, 0, 0), 4 (12, 14, 0, 0, 0, 0), 5 (12, 15, 0, 0, 0, 0)
    Column count doesn't match value count at row 1

    colored numbers are just count how many fields u are tryin  to update, and how many values. so, I'd say that the mismatch: 12 fields, but only 5 of them set values.
    Logged

    Your first three "must do" before you ask a question:
    Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
    Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)
    Pages: [1] 2 3 4 5 » »» Print 
    « previous next »
    Jump to:  

    Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
    Page created in 0.192 seconds with 20 queries.