View Full Version : greater than or less than searches?
rschletty
02-05-2009, 08:11 PM
Is there a way to customize Zoom Search to do "greater than X" and "less than X" searches? For example, I want to search nutrition fields in an Access database with a search option like this:
"Find all recipes that contain less than 5 grams of fat."
I checked out the Zoom Search Engine FAQ - Indexing databases (http://www.wrensoft.com/zoom/support/databases.html) thread but did not find an answer. We have set up nutrition fields (columns) in the database and have entered all the numeric data values. We are not trying to do > < math from a nutrition list like you see on a cereal box. That would be well nigh impossible to do.
Our alternative is to do custom ASP coding that searches the .db database and returns the results to a page other than the Zoom search results page. The problem with this is that searches from this custom search form would not show up in the Zoom Search log. Is there a way to integrate? I'm sorry of I sound a bit green and fuzzy. I am new to this level of code tweaking.
wrensoft
02-05-2009, 08:46 PM
Have a look at the custom meta fields feature (in the Users Guide (http://www.wrensoft.com/zoom/usersguide.html)).
There is also a similar demo here (http://www.wrensoft.com/zoom/demos/fruitshop/cgi-bin/advanced_search.html), with the ability to search for maximum price.
Yes, the Numeric data type for Custom Meta Fields can perform the following search criterias:
Exact match
Less than
Less than or equal to
Greater than
Greater than or equal to
rschletty
02-06-2009, 05:38 AM
Awesome! This is good news. Thank you.
However, just to clarify, there is no way to have both a >= and a <= on the same numeric value,
so there is no way to find all recipes that have more than 3grams of fat, but less than 10grams.
That is too bad.
I just realized a hack workaround. If you duplicate the item as a different meta value, so if your recipe has GRAMS = 5, then create a GRAMS2 = 5, then create a custom field for GRAMS as being >= and GRAMS2 as <= and it will work. However, it returns both fields on the results page, so it looks kinda bad.
But fortunately for me, Im using cgi/xml so I can post-process my results and not show GRAMS2 in this scenario. I lost a feature (highlighting - I still want that back, btw :) ) with cgi/xml. I guess now I gain a feature!
We had thought about doing a Range match but it was left on the list as something for the future (given that we weren't sure how many people would even bother with setting up the Custom Meta Fields as it is). If there's enough demand, we will certainly consider it for the future.
I just realized a hack workaround. If you duplicate the item as a different meta value, so if your recipe has GRAMS = 5, then create a GRAMS2 = 5, then create a custom field for GRAMS as being >= and GRAMS2 as <= and it will work. However, it returns both fields on the results page, so it looks kinda bad.
You can hide the redundant field via CSS. Because each meta field has its own CSS class, you can suppress any or all of them with the "display: none" attribute.
But fortunately for me, Im using cgi/xml so I can post-process my results and not show GRAMS2 in this scenario. I lost a feature (highlighting - I still want that back, btw :) ) with cgi/xml. I guess now I gain a feature!
We'll probably revisit the highlighting in a few weeks time. We just need to determine what is the best (most accepted) way of doing it, without breaking other users handling of the current XML, and maintain OpenSearch compatibility.
rschletty
02-09-2009, 03:19 PM
Thanks for your ideas. There is no need to do a range. In most cases < X will do fine. In other words, people want to find recipes low in calories, sodium, fat, carbs, cholesterol, sugars, etc. But they only search on one value at a time. They may also want to look for recipes high in fiber. That would be a > search. Here are the columns as they appear in Access:
http://www.schlettydesign.com/ggf/nutrition_fields.jpg
[QUOTE=Ray;12218]We had thought about doing a Range match but it was left on the list as something for the future (given that we weren't sure how many people would even bother with setting up the Custom Meta Fields as it is). If there's enough demand, we will certainly consider it for the future.
Hi, I was wondering if you have given any more thought to allowing a range to be created in the search page. I am working on a real estate site and would like to have a range that people could plug in for $ min and max. (as they do on craigslist for example). If I just set a maximum dollar amount only, you would pull a lot of homes that you had no interest in.
Thank you
We haven't had much demand for it yet, but we're noting your request. If there's more demand we might include it in a V6.1 release.
Note the workaround that Danf suggested above in this thread. That is, you can achieve the same result at the moment using two tags/fields with the same value on the page, but indexed differently, and use CSS to suppress the redundant field from showing in the search results.
Powered by vBulletin® Version 4.1.12 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.