搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

Address book query syntax

  • 4 回覆
  • 0 有這個問題
  • 15 次檢視
  • 最近回覆由 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.

被選擇的解決方法

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)

從原來的回覆中察看解決方案 👍 0

所有回覆 (4)

more options

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

有幫助嗎?

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?

有幫助嗎?

more options

選擇的解決方法

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)

有幫助嗎?

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

有幫助嗎?

問個問題

如果您還沒有帳號,您必須先登入帳號 來回覆文章。還沒有帳號的話,只能發問新問題