Logic question

Hi,

I have had an interesting experience when using OR while searching.

If I search for

fieldA=x OR fieldB=y

then the search fails.If i turn it around and search for

fieldB=y OR fieldA=x

then it gives me all the results. It doesn’t matter if i use the notes client or a web browser, the same thing happens.

fieldB is located physically lower on the form than fieldA and is also alphabetically after fieldA (not sure if either could, would or should make a difference). They are both dialog list fields and get their values using dbcolumn formulas on different views in the same database.

I know i come from the land down under and the way we do things sometimes seems a bit back to front but this doesn’t make a lot of sense to me.

Is it just a quirk, or is there something wierd going on?

TIA

Lisa

Subject: Logic question

Lisa,

Are you manipulating the values in the UI or in the backend doc?

Brandt

Subject: RE: Logic question

Brandt,

I have tried both. It wasn’t working when I tried the back end so I tried the front end.

On the browser I’ve tried typing the search directly into the address bar, triple checking the syntax is correct each time and it works when its “fieldB=y or fieldA=x” but not “fieldA=x or fieldB=y”. Notes client search, same deal.

I had to rewrite the code for searching when it would only work one way around but not the other.

Its confusing and frustrating as I can’t see why it should make any difference. As far as I’m concerned they should give me the same results.

I’ve deleted and recreated the index as well in case the index was corrupted.

Thanks

Lisa

Subject: RE: Logic question

Lisa,

would you mind posting all of the code? It might be easier to see what is causing the issue then.

Brandt

Subject: RE: Logic question

This is the version that works at the moment, well for the most part anyhow.

Have gone back to formula language as lotusscript and javascript were getting too ugly and confusing and more importantly not working.

At the end of the day, the code isn’t that important. My question is more why i have to combine fields in a certain order to get them to work when to my twisted sense of logic, I should be able to put them on either side of an AND or an OR and get the same answers. x or y should be the same as y or x

simplied version of the form (minus the javscript and css):

fields:

SearchType - radio button - Delegation / Authorisation|1, Exemption|2. Used to set the formtype below

SearchLookFor - radiobutton - Any|2, All|1

Act - listbox - “None”:@DbColumn(“”:“NoCache”;“”;“AllActs”;1)

Regulations - listbox - “None”:@DbColumn(“”:“NoCache”;“”;“AllRegs”;1)

Position - listbox - “None”:@DbColumn(“”:“NoCache”;“”;“Positions”;2)

Word1, Word2, Word3, Word4, Word5, Word6, Word7, Word8 - 8 text field

CreateModify - listbox - effective date|[GazettalDate]. additional options when admin users logged in.

BeforeAfter - listbox - on|=, from|>=, before|<=

QueryDate - text - javascript date picker and validation

DateChoice - listbox - effective date|[GazettalDate]. additional options when admin users logged in.

AfterDate - text - javascript date picker and validation

BeforeDate - text - javascript date picker and validation

FormType - listbox - All | FILALL, Delegations | DelAll, Authorisations | AuthAll

SearchMaxResults - listbox - All | 0, 10, 50, 100

Search code in full.

REM {if nothing is selected, display 2nd search form with error message advising user need to select something to search for. 1st option in each keyword field is None and there is no default set};

@If((Act=“None” | Act=“” )& (Regulations =“None” | Regulations=“”) & (Position =“None” | Position = “”) & Word1=“” & Word2=“” & Word3=“” & Word4=“” & Word5=“” & Word6=“” & Word7=“” & Word8=“” & QueryDate=“” & AfterDate=“” & BeforeDate=“”; @Return(“[/”+@WebDbName+“/WSAdvanced2]”);@Success);

REM {set up AND or OR for the rest of the search. Default is OR};

x:=@If(SearchLookFor=“1”;" AND “;SearchLookFor=“2”;” OR “;”");

REM {if text entered in word fields, combine them. trying to accomodate the fact that people might enter test in box other order than top-left to bottom–right};

words8:=@If(Word1!=“”;Word1;“”);

words7:=@If(words8!=“” & Word2!=“”; words8 + x + Word2; words8=“” & Word2!=“”; Word2; Word2=“” & words8!=“”; words8;“”);

words6:=@If(words7!=“” & Word3!=“”; words7 + x + Word3; words7=“” & Word3!=“”; Word3; Word3=“” & words7!=“”; words7;“”);

words5:=@If(words6!=“” & Word4!=“”; words6 + x + Word4; words6=“” & Word4!=“”; Word4; Word4=“” & words6!=“”; words6;“”);

words4:=@If(words5!=“” & Word5!=“”; words5 + x + Word5; words5=“” & Word5!=“”; Word5; Word5=“” & words5!=“”; words5;“”);

words3:=@If(words4!=“” & Word6!=“”; words4 + x + Word6; words4=“” & Word6!=“”; Word6; Word6=“” & words4!=“”; words4;“”);

words2:=@If(words3!=“” & Word7!=“”; words3 + x + Word7; words3=“” & Word7!=“”; Word7; Word7=“” & words3!=“” ; words3;“”);

words:=@If(words2!=“” & Word8!=“”; words2 + x + Word8; words2=“” & Word8!=“”; Word8; Word8=“” & words2!=“”; words2;“”);

REM {set up searching for on, from and before a single date. Aliases used in BeforeAfter field: on|=, from|>=, before|<= };

date:=@If(QueryDate!=“” & CreateModify!=“” & BeforeAfter!=“”; CreateModify + BeforeAfter + QueryDate;“”);

REM {set up searching for date range. set up for after (>=) and before (<=). if dates entered round wrong way, search won’t present correct search};

daterange:=@If(DateChoice!=“” & AfterDate!=“” & BeforeDate!=“”; DateChoice + “>=”+ AfterDate +" AND " + DateChoice + “<=” + BeforeDate ;“”);

REM {combine search on Act and Position fields with operator. Tried with Regulation originally but that wasn’t working so went with position instead. used to enclose field names. “” used around search term so phrase is searched for };

searchfor1:=@If((Act!=“” & Act !=“None”) & (Position!=“” & Position!=“None”);“[Act]="” + Act +“" " + x + " [Position]="”+Position+“"”; ((Act=“” | Act =“None”) & (Position!=“” & Position!=“None”));“[Position]="”+Position+“"”; ((Position=“” | Position =“None”) & (Act!=“” & Act !=“None”)) ;“[Act]="”+ Act +“"”; “”);

REM {combine results of Act and Position combination with search on Regulations. Note field name on data entry forms is Regulation. This is different to Regulations on the search form. Tried with Regulation originally but that wasn’t working so went with regulations instead. };

searchfor2:=@If((searchfor1!=“” & searchfor1!=“None” ) & (Regulations!=“” & Regulations!=“None” ); “[Regulation]="”+Regulations+“"” + x + searchfor1; ((searchfor1=“” | searchfor1=“None” ) & (Regulations!=“” & Regulations!=“None” )); “[Regulation]="”+Regulations + “"”; ((Regulations=“” | Regulations=“None”)&(searchfor1!=“” & searchfor1!=“None” )); searchfor1;“”);

REM {combine results of Act, Position, Regulation combination with values from word fields};

searchfor3:=@If((searchfor2!=“” & searchfor2!=“None”) & words!=“”; searchfor2 + " " + x +" " + words; ((searchfor2=“” | searchfor2=“None”) & words!=“” ); words; (words=“” & (searchfor2!=“” & searchfor2!=“None”) ); searchfor2;“”);

REM {add the single date comparison in};

searchfor4:=@If(searchfor3!=“” & date!=“”;searchfor3 + x + date; (searchfor3=“” & date!=“” ); date; (date=“” & searchfor3!=“”) ; searchfor3;“”);

REM {add the date range comparison in to the mix};

searchfor:=@If(searchfor4!=“” & daterange!=“”; searchfor4 + x + daterange; (searchfor4=“” & daterange!=“”) ; daterange; (daterange=“” & searchfor4!=“” ); searchfor4;“”);

REM {set up maximum number of results to return. If All is chosen, there is only the notes limit of 5000};

options:=@If( SearchMaxResults=“0”; “”; “&SearchMax=” + SearchMaxResults );

REM {run search and present results};

“[/”+@WebDbName + “/”+FormType+“?SearchView&Query=” + searchfor + “&SearchOrder=4” +Options + “]”