Can I search for my own fields and use multiple inputs with drop-down boxes like a database query?
Yes! Combo searching (as we call it) was suggested to us by a user, and
we were glad to support it because it's such a great idea. Searching
multiple inputs is one of the tricks that is easily supported by our Boolean engine.
The essential idea is that you can call your search engine with more
than one term input, so that one search button can go find the results
for several dropdown boxes and/or text boxes in combination. The
multiple queries will be strung together logically, with unused ones
being ignored, and voila! Your users will get search results similar to
what the fields of a database query form would return.
Of course PicoSearch is not a database indexer or searcher
explicitly. But if you set up your links and pages appropriately, with
one HTML document per data entry, you'll have in this way a nice product
catalog or information records retrieval system. Each search unit in
the combo could even be a standardized field and value pair, quoted when
searched to hold together as a phrase, such as "State: New York" or
"Date: Feb-09-2000". You should experiment to find and stick with the
phrase formats that will work for you and your search engine, because
it's up to you to keep these words together. When you're done, you'll
have database accuracy without the usual database hassles or costs!
Now for the details. We'll assume that you have some basic HTML
understanding, and you already know that you can get all the code for
your PicoSearch searching box from the link in your account manager "How
to Add a Search Box". This is where you should begin. The additional
inputs you will be adding should all go within the scope of the FORM
tags, since that is where the call to PicoSearch is made. What you want
to do is retain a single <input type="submit" name="search" />
for the button, and decide whether or not you want to keep the plain
<input type="text" name="query" /> for a user input query box
(compare with a qAndAll input type below). Then, you want to insert
additional inputs, most likely a few dropdown boxes that you will preset
for quick querying values, as in the following example:
These would then appear as additional information inputs next to your
main search box and button, and they will contribute their selections to
the search launch as long as they are within the scope of your original
cut-and-paste search code.
More search terms:
When you hit the search button for this example, any
selected non-empty value (the default unselected choice is empty) will
be added to the rest of a search with the + sign, so that the term or
phrase must be found on any matching documents. This means that if
someone typed in italian and selected the chair from the dropdown, the total query would be italian +"product: chair". If they selected the foot stool, the total query would be italian +"product: foot stool".
These queries would then work great in a site that had separate
documents for each showcased product, where a typical document said
something like "Product: Chair. Material: Oak. Comments: What a great
Italian design!"
You can see now why it would be a good organizational practice to keep critical field names like product: next to key words, so that you won't get false hits from the same words
being used elsewhere. Otherwise your user looking for a chair might
get the following false result; "Sofa. Italian. Looks great next to the
chair!"
Notice also that the queries mentioned above don't enforce the user's keyword of italian,
but only will tend to bring up Italian matches first. To absolutely
require Italian in the returns, you would want a total query of +italian +"product: foot stool".
This would happen if the name of the user's input text was itself an
And type, which it certainly can be set for (see qAndAll input type
below).
The types and rules of different inputs for combo query
building are as follows. Choose the additional input names that suit
your needs, and be sure to use each name only once. If you need to
specify a quoted phrase within the VALUE="..." attribute of an input,
use %22 so as to not end the HTML value prematurely. In this way you
can build up your querying form on your own web pages. If you have a
paid account, you can put this form into your result page template as a custom search box or you can direct users back to the search form on your site. You can
have as many input arguments of the following names as long as they
start with the name and the ending is unique, for example qAppend1 and
qAppend2 or qAppend1b, but not another qAppend1.
qAppend: any INPUT or SELECT field name starting with qAppend
will be appended without modification onto the combined search. No
other processing is done, so you must be certain that what you intend is
specified in the value. Ex: name=qAppend2 value="+stock -%22stock
market%22" => Search: +stock -"stock market"
qAndExact: any INPUT or SELECT field name starting with
qAndExact will be appended as a single required term or phrase onto the
combined search using the + sign. Quotes will be added around multiple
words as needed to make a phrase. Ex: name=qAndExact4 value="stock
market" => Search: +"stock market"
qNotExact: any INPUT or SELECT field name starting with
qNotExact will be appended as a single excluded term or phrase onto the
combined search using the - sign. Quotes will be added around multiple
words as needed to make a phrase. Ex: name=qNotExact1 value="stock
market" => Search: -"stock market"
qAndAll: any INPUT or SELECT field name starting with qAndAll
will be appended onto the combined search with the + sign added to
every term or phrase which is not already within parentheses or modified
by its own boolean (AND, OR, NOT, +, -). This property is good for
lists of required terms in a dropdown, and also makes this input type a
good candidate for replacing the plain name=query box input (the one
that comes with the cut and paste). By using qAndAll instead of query,
whatever the user types is likely to get correctly required in
combination with other inputs, and this is probably what the user will
expect in a total search form. Ex: name=qAndAll2 value="stock market"
=> Search: +stock +market
qAndAny: any INPUT or SELECT field name starting with qAndAny
will be appended onto the combined search as a boolean list of
alternates formatted as the conjunction of disjunctions, ie. AND ( term1
OR term2 OR term3 ). What's more, the qAndAny inputs, when used with
the plain query input, will force the query input to combine in
parentheses with this form, ie. if the user types two terms with nothing
between them, the implication of one of them appearing will create a
total search of (userterm1 OR userterm2) AND (term1 OR term2 OR term3).
Other input types are not affected, so they may or may not combine well
depending on how you have set things up. The conjunction of
disjunctions is very powerful, allowing the logical buildup of any
query, so this input type may be needed in complex search designs. Ex: name=qAndAny1 value="%22new york%22 Tokyo" ... name=qAndAny2 value="stock market" => Search: ("New York" OR Tokyo) AND (stock OR market)