At the moment I'm working on a Flex app that will allow the user to build their own views from backend Notes data. It's a bit like a Search Builder and you can see the guts of it in the Flex app embedded below:
You can use the "Add New Filter" button to add new filters/search terms. The dropdown that says "Title" in it (by default") allows you to select the field and then (depending on what type of field it is) you can tailor the filter by text, number or date.
When you've added all the filters you press the "build" button and it will display the proposed view selection criteria in the white box.
It works. Kind of. Where it falls down is its handling of the AND OR logic. I just can't get my head round it and [invoke lazy web now] I wondered if you could help.
How should a Search Builder compile the search terms with AND OR logic?
Consider the following terms:
At the moment the app comes up with the following search string:
SELECT title="Hello" | date_created < [02/24/2009] & unit_value<50
Surely that's wrong. Shouldn't it be:
SELECT ( title="Hello" | date_created < [02/24/2009] ) & unit_value<50
Or should it be:
SELECT title="Hello" | (date_created < [02/24/2009] & unit_value<50)
The results of both are different, but how would it know which to assume the user meant?
It gets more complicated as you add more and more terms and I can't decide the best way to deal with it. Anybody know how to do it or of an example that already does?