Webmastersite.net
Register Log In

searching multiple fields
using one condition for multi fields search

Comments on searching multiple fields

knotworking
Experienced

Usergroup: Customer
Joined: Mar 31, 2004

Total Topics: 20
Total Comments: 83
Posted May 10, 2005 - 8:19 PM:

I would like to keyword search 6 similiar fields in my database which are all used to list cities that are close to the member. I understand how to use fieldcondition on a membersearch to specify one field to search but, how would I write a condition that does a keyword search on several member fields at the same time, say "san francisco?"
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted May 11, 2005 - 9:30 PM:

The simple search does that with your searchable fields, and you can use the advanced search to filter to require the text in all of several fields, but there's no 'or' option in the advanced search.
knotworking
Experienced

Usergroup: Customer
Joined: Mar 31, 2004

Total Topics: 20
Total Comments: 83
Posted May 12, 2005 - 6:46 AM:

The simple search only searches the selected general fields provided at the bottom of the functionality page in the admin panel, right? I could see no way to add searchable fields to that selection list. Is there a way to add my custom fields to the simple search all?
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted May 13, 2005 - 3:19 AM:

Custom fields are added to the simple search by, as you just noted, going to the bottom of the functionality page in the admin panel. I don't see how you can not see how to do it there. perhaps you can explain the difficulty.
knotworking
Experienced

Usergroup: Customer
Joined: Mar 31, 2004

Total Topics: 20
Total Comments: 83
Posted May 13, 2005 - 7:35 AM:

Well, here's what I see. There's a field for excluding custom search fields:
"Exclude these custom fields from search highlighting"

Then below that there's the Searchable Fields selector box, where you hold down ctrl to select multiple fields (but the only fields in the selector box are native to WSNG, none of my custom fields).

Below these are then the submission required fields and various parsing fields for smileys and line breaks, etc.

And that's it from what I can see. No area for adding fields to the simple search, just the field for excluding custom fields. I've attached a pdf screenshot of what I am seeing.

Attached Files:
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted May 13, 2005 - 9:29 AM:

I thought you were talking about searchable fields, not highlighting. Anyhow a screenshot is attached. There is no distinction between "native" and "custom" fields anywhere, a field is a field... and certainly it shows the "custom" field clarityrating I have there which isn't in default installs.

Attached Files:
knotworking
Experienced

Usergroup: Customer
Joined: Mar 31, 2004

Total Topics: 20
Total Comments: 83
Posted May 13, 2005 - 1:49 PM:

I was not able to download the attached jpeg screenshot (kept getting a message saying I wasn't allowed by the admin) but, judging by the thumbnail image, that is exactly where I thought I should be able to select my custom fields for searching (not concerned with highlighting). The problem is that there are none of my fields in the list. The only fields in the list are those that come with the gallery. I have looked it over a half dozen times but, none of my fields are listed.

My custom fields show up in the Customizations 'Add Fields'list and I can use them fine in all other areas. They just aren't in the search fields list. Is there something I should be doing to make them selectable?
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted May 14, 2005 - 3:25 AM:

It is really impossible for any image field to be treated differently than any other. There is nowhere in the script that it is ever told what the default fields are, so it has no way to favor them. (Most all the default fields were in fact added through the 'add fields' page.)

Forgot about the usergroup restriction on attachments. You can view it now.

Edit: Hm, are you talking about members? The simple search, of course, is for searching images.
knotworking
Experienced

Usergroup: Customer
Joined: Mar 31, 2004

Total Topics: 20
Total Comments: 83
Posted May 14, 2005 - 6:06 AM:

That's where the confusion was (sorry about that), I am talking about members fields. Can I switch the simple search by replacing the references to the images table with the members table in the code? I really need to be able to do one multiple field search and I'll never really use the images search.
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
#10 - Quote - Permalink
Posted May 14, 2005 - 10:42 PM:

Either adding a <option value="members">members</option> to <select name="whichtype"><option value="images">search images</option><option value="all">search all</option></select> works or there is no member simple search. I haven't checked.
knotworking
Experienced

Usergroup: Customer
Joined: Mar 31, 2004

Total Topics: 20
Total Comments: 83
#11 - Quote - Permalink
Posted May 15, 2005 - 9:58 AM:

Adding the members option enabled the simple search on all member fields as you thought it might.

I got into the admin functionality.tpl, opened prefs.php, and changed the code:
$searchfieldsmenu = fieldselector('linkfields', $settings->searchfields);
to
$searchfieldsmenu = fieldselector('memberfields', $settings->searchfields);
which allowed me to select my member fields instead of image fields in the functionality menu.

Unfortunately, the simple search is still searching all member fields. I obviously need to change something else so that it references the fields I've selected in the functionality menu. I am fooling around in search.php but, so far no dice. Do you know where these variables lie?
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
#12 - Quote - Permalink
Posted May 16, 2005 - 3:57 AM:

You would basically have to rewrite the whole search.php, I would think. Perhaps just changing specific $settings->memberfields instances would work, but I doubt it. Anyhow I can't support it.
knotworking
Experienced

Usergroup: Customer
Joined: Mar 31, 2004

Total Topics: 20
Total Comments: 83
#13 - Quote - Permalink
Posted May 16, 2005 - 5:19 AM:

Yeah, I figured I might be stretching the limits of support (I was hoping there might be a quick hack). I'll fool around with it a little and see if that replace in the script will work.

oK,
I went through and replaced about three references of
$settings->memberfields
with
$settings->searchfields
and, it works (sortof). There is only one problem, the members search and simple search seem to both rely on this part of the code:
$searchmemfields = explode(',', $settings->memberfields);
which I changed to:
$searchmemfields = explode(',', $settings->searchfields);
so, now my advanced members search can only search the specific field if it is selected on the functionality list.

This is not all that bad, though. It would be great to be able to exclude all the false positives that might come up on a city keyword search when a member's name is 'Vegas' or something. I am no longer searching ALL member fields with the simple search (only those that must be selected for the advanced search and simple search to work) which works good enough at this point.
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



This thread is closed, so you cannot post a reply.