Alternative search forms / results

To make sure our users do not have to adapt too much to a new way of searching, we are making an alternative search form. We're having a few problems with doing this.

Public searching

Only a certain amount of fields should be searchable, so we made a smaller list for showing input fields.
The standard search type for all these fields should be: "contains". So we set al advanced[$i][type] to "contains". The problem now is, that the query becomes huge because LIKE %% is filled in for all the fields:

AND (_advanced_4.text LIKE '%%') AND (_advanced_5.text LIKE '%%') AND (_advanced_6.text LIKE '%%') AND (_advanced_7.text LIKE '%%') AND (_advanced_8.text LIKE '%%') ... etc

Is it perhaps a suggestion to not search for a value at all when nothing is filled in? Or do you have another suggestion on how to solve this? Or is there a way to expand the standard search functionality?

Confusing search functionality

Another confusion for the user might be that when you go to "advanced search" from the simple search box, the previous search values stay in place. Yet when the "search items" link (in the advanced search screen) is clicked, one is directed to an empty form. It would perhaps be better to keep this functionality the same, and install a reset button.

Admin searching

Now that I've found out how to change the search form for the public site, I would like the same format for the admin site. But how do I do this? Are you planning the same type of freedom for the admin theme any time soon? Or can I replace it somehow by building a plugin?

The same for the simple search results in admin mode: A lot of items don't have a Title so there is absolutely no information at all when a simple search is performed in the admin view. I'm making more and more changes to the public theme search, which slowly turns it into something totally different than the admin theme. This is becoming a bit confusing for the item importers/annotators.

Inclusive / exclusive search

Also (maybe not suitable for this thread), would it be possible to make some function for inclusive/exclusive search in the advanced search form?

The search automatically excludes "rows" that don't have both a type and an element_id. The element_id's shouldn't be getting set, from what you describe, but I'm not sure how your new form works.

For the confusing search links, which link are you talking about that doesn't work the way you expect?

As for the admin theme, you can make a different one, but there's no accessible way to change the current admin theme, you'd have to do that directly in the database, and you'd have to start from a total copy of the "default" admin theme.

searching

My new form works with a standard type setting. This setting is "contains". I have a selection of fields that can be searched. These are all shown in the form so that the user doesn't have to search through the entire list of metadatafields, and also select from the search type list. The form results in something like this:

advanced[0][element_id]=43&
advanced[0][type]=contains&
advanced[0][terms]=mop&
advanced[1][element_id]=50&
advanced[1][type]=contains&
advanced[1][terms]=&
advanced[2][element_id]=49&
advanced[2][type]=contains&
advanced[2][terms]=&

which results in this:

SELECT items.* FROM omeka_items AS items
INNER JOIN omeka_collections AS collections ON items.collection_id = collections.id
INNER JOIN omeka_element_texts AS _advanced_0 ON _advanced_0.record_id = items.id AND _advanced_0.record_type = 'Item' AND _advanced_0.element_id = 43
INNER JOIN omeka_element_texts AS _advanced_1 ON _advanced_1.record_id = items.id AND _advanced_1.record_type = 'Item' AND _advanced_1.element_id = 50
INNER JOIN omeka_element_texts AS _advanced_2 ON _advanced_2.record_id = items.id AND _advanced_2.record_type = 'Item' AND _advanced_2.element_id = 49 WHERE (collections.id = '1') AND (_advanced_0.text LIKE '%mop%') AND (_advanced_1.text LIKE '%%') AND (_advanced_2.text LIKE '%%') GROUP BY items.id ORDER BY items.added DESC LIMIT 25

So the database thinks I'm looking for elements that contain "". And if I do this for the 20 fields that we think are most important for searching, it creates a very long query that takes forever. I think it should maybe also exclude rows that don't have a "terms".
I don't know how to describe it better I suppose.

Confusing search link

The confusing part is the difference in what happens when you access the advanced search from the simple search (in the header), and what happens when you access the advanced search from the "secondary-nav". The search values remain filled in when the advanced search is accessed through the first option, but through the second option, the search form is emptied.

Searching in admin mode

Thanks for this tip. I wasn't aware that the admin theme could be set in the settings in the database. This way I can keep functionality between the public site and the admin site similar.

I do not have any helpful suggestions, but I am attempting to do something similar, but have not gotten as far as you. Wondering if you would mind sharing some code? Are you writing it as a plugin?

Thanks,
-Winona
wsalesky@gmail.com

I'm still not sure I get the explanation of your custom form.

So, there are no longer any HTML select boxes in that section of the page, just many text boxes always pre-loaded? I understand that the "type" is preselected (as a hidden field I assume), but the elements are also preselected?

@John:

That's correct. We've selected a bunch of fields (this selection is done in the settings of a plugin that goes with the theme). The element_id's are preselected and hidden. The "type" is preselected, but not hidden (just set to "contains" to decrease clicking and search mistakes).

Like so: http://bookstore.ewi.utwente.nl/vb/items/search?style=advanced (here the type is not preselected because of the issues described above)

@wsalesky:

Here is how I am building our simpler search form:
https://github.com/iwemuiser/theme-verhalenbank/blob/master/items/search-form-medium.php

it's possible to load 2 kinds of search forms. This is set in search.php: https://github.com/iwemuiser/theme-verhalenbank/blob/master/items/search.php

Please note that it is not finished!

Thanks! That is really helpful.

Hmmm, ok.

The system's, as I said, set up to ignore search "rows" that don't have an ID or a type set on them. We can't have a blanket ignore for an empty text box, because the "is empty" and "is not empty" types need to be able to work with no entry in the box.

We could extend the checking to ignore fields with no search terms, but only for the contains and exact search types. I'm not sure if/when that would make it into a release, though.

That would be great. It will create a lot more options to make custom forms.

Is it also possible to make this functionality in the form of a plugin?

We are also interested in search actions in multiple fields. So, basically an OR function. Also, we are looking to extend the simple search to be able to look in certain collections. Do you see an opportunity for a plugin to extend this functionality? If yes, could you give me a hint on where to start looking?