Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Address book query syntax

  • 4 replies
  • 0 have this problem
  • 16 views
  • Last reply by geoffsm

more options

Is the syntax for the address book query described anywhere? (as in mail.addr_book.autocompletequery.format) Specifically, I want to match fields "starting with" the input value, not "containing" it. I also want to prefer address from one specific address book (i.e. list those addresses first) without completely excluding addresses from the others.

Is the syntax for the address book query described anywhere? (as in mail.addr_book.autocompletequery.format) Specifically, I want to match fields "starting with" the input value, not "containing" it. I also want to prefer address from one specific address book (i.e. list those addresses first) without completely excluding addresses from the others.

Chosen solution

Hello

looking at the Javascript code (AbAutoCompleteSearch.jsm) gives some insights, and they are not pretty. First of all, the default search is hardcoded in Javascript. As soon as you change something, the whole process is changed to call a c++ search done on the address book files (so it may be quite slower), and there are quite a few quirks - you can invalidate the email match all that you want, it will be ignored. Now the c++ syntax is in nsAbQueryStringToExpression.cpp:

 if (PL_strcasecmp(condition, "=") == 0)
   c = nsIAbBooleanConditionTypes::Is;
 else if (PL_strcasecmp(condition, "!=") == 0)
   c = nsIAbBooleanConditionTypes::IsNot;
 else if (PL_strcasecmp(condition, "lt") == 0)
   c = nsIAbBooleanConditionTypes::LessThan;
 else if (PL_strcasecmp(condition, "gt") == 0)
   c = nsIAbBooleanConditionTypes::GreaterThan;
 else if (PL_strcasecmp(condition, "bw") == 0)
   c = nsIAbBooleanConditionTypes::BeginsWith;
 else if (PL_strcasecmp(condition, "ew") == 0)
   c = nsIAbBooleanConditionTypes::EndsWith;
 else if (PL_strcasecmp(condition, "c") == 0)
   c = nsIAbBooleanConditionTypes::Contains;
 else if (PL_strcasecmp(condition, "!c") == 0)
   c = nsIAbBooleanConditionTypes::DoesNotContain;
 else if (PL_strcasecmp(condition, "~=") == 0)
   c = nsIAbBooleanConditionTypes::SoundsLike;
 else if (PL_strcasecmp(condition, "regex") == 0)
   c = nsIAbBooleanConditionTypes::RegExp;
 else if (PL_strcasecmp(condition, "ex") == 0)
   c = nsIAbBooleanConditionTypes::Exists;
 else if (PL_strcasecmp(condition, "!ex") == 0)
   c = nsIAbBooleanConditionTypes::DoesNotExist;

but do not have too high expectations, some things may not be implemented (soundslike is not)

Read this answer in context 👍 0

All Replies (4)

more options

I am confused. The ability to search for a starting value is already there.

Helpful?

more options

Starting with the default value as provided for the option: mail.addr_book.autocompletequery.format = (or

 (DisplayName,c,@V)
 (FirstName,c,@V)
 (LastName,c,@V)
 (NickName,c,@V)
 (PrimaryEmail,c,@V)
 (SecondEmail,c,@V)
 (and
   (IsMailList,=,TRUE)
   (Notes,c,@V)
   )    
 )

I can puzzle out most of what this is doing, I think. I am guessing that the ",c," means "contains" because that is how it behaves: i.e The auto-complete drop-down includes entries where my search term exists anywhere in any of the named the fields. I can also guess that ',=,' means "is equal to": The entire named field must be the same as my search term (or a literal value as in the example). That I have confirmed by playing around with the option and watching how it behaves. So my question really is: Is this part of a bigger syntax? I just don't recognize it. If so, can I get hold of a description of the whole syntax somewhere?

Helpful?

more options

Chosen Solution

Hello

looking at the Javascript code (AbAutoCompleteSearch.jsm) gives some insights, and they are not pretty. First of all, the default search is hardcoded in Javascript. As soon as you change something, the whole process is changed to call a c++ search done on the address book files (so it may be quite slower), and there are quite a few quirks - you can invalidate the email match all that you want, it will be ignored. Now the c++ syntax is in nsAbQueryStringToExpression.cpp:

 if (PL_strcasecmp(condition, "=") == 0)
   c = nsIAbBooleanConditionTypes::Is;
 else if (PL_strcasecmp(condition, "!=") == 0)
   c = nsIAbBooleanConditionTypes::IsNot;
 else if (PL_strcasecmp(condition, "lt") == 0)
   c = nsIAbBooleanConditionTypes::LessThan;
 else if (PL_strcasecmp(condition, "gt") == 0)
   c = nsIAbBooleanConditionTypes::GreaterThan;
 else if (PL_strcasecmp(condition, "bw") == 0)
   c = nsIAbBooleanConditionTypes::BeginsWith;
 else if (PL_strcasecmp(condition, "ew") == 0)
   c = nsIAbBooleanConditionTypes::EndsWith;
 else if (PL_strcasecmp(condition, "c") == 0)
   c = nsIAbBooleanConditionTypes::Contains;
 else if (PL_strcasecmp(condition, "!c") == 0)
   c = nsIAbBooleanConditionTypes::DoesNotContain;
 else if (PL_strcasecmp(condition, "~=") == 0)
   c = nsIAbBooleanConditionTypes::SoundsLike;
 else if (PL_strcasecmp(condition, "regex") == 0)
   c = nsIAbBooleanConditionTypes::RegExp;
 else if (PL_strcasecmp(condition, "ex") == 0)
   c = nsIAbBooleanConditionTypes::Exists;
 else if (PL_strcasecmp(condition, "!ex") == 0)
   c = nsIAbBooleanConditionTypes::DoesNotExist;

but do not have too high expectations, some things may not be implemented (soundslike is not)

Helpful?

more options

Thank you, gp. This gives me some of what I need and provides pointers to the rest. Parsing little languages is never pretty. This fragment is at least clear about what it is doing. Geoff

Helpful?

Ask a question

You must log in to your account to reply to posts. Please start a new question, if you do not have an account yet.