Microsoft graph Mail Search Strict value - email

I have an issue with the search parameters. I want to pass a phrase in my query. For exemple i'm looking for emails where the subject is "Test 1".
For this i'm doing a get on this ressource.
https://graph.microsoft.com/v1.0/me/messages?$search="subject:Test 1"
But the behaviour of this query is : Looking for mails that contains "Test" in the subject OR 1 in any other fields.
Refering to the KQL Syntax
A phrase (includes two or more words together, separated by spaces; however, the words must be enclosed in double quotation marks)
So, to do what i want i have to put double quotes (") around my phrase to do a strict value search. Like below
subject:"Test 1"
The problem it's at this point. Microsoft graph api already use double quotes (") after the parameters $search.
?$search="Key words"
So I can't do what is mentioned in the KQL doc.
https://graph.microsoft.com/v1.0/me/messages?$search="subject:"Test 1""
It's throwing an error :
"Syntax error: character '1' is not valid at position 15 in '\"subject:\"test 1\"\"'.",
It's an expected behaviour. I was pretty sure it will not work.
If someone has any suggestions for a solution or a workaround, I'm a buyer.
What I've already tried so far :
Use simple quote
Remove the quotes right after $select=
Remove the subject part $select="Test 1", same behaviour as the first request mentioned in this post. It will looks for emails that contain "test" or "1".
Best regards.
EDIT :
After sasfrog's anwser :
I used $filter : It works well with simple operator AND, OR.I have some errors by using the Not Operator. And btw you have to use the orderby parameter to show the result by date and add the field in filter parameters.
Exemple 1 (working, what I asked for first) :
https://graph.microsoft.com/v1.0/me/messages/?$orderby=receivedDateTime desc &$filter=receivedDateTime ge 1900-01-01T00:00:00Z AND contains(subject,'test 1')
Exemple 2 (not working)
https://graph.microsoft.com/v1.0/me/messages/?$orderby=receivedDateTime desc &$filter=(receivedDateTime ge 1900-01-01T00:00:00Z AND contains(subject,'test 1')) NOT(contains(from/EmailAddress/address,[specific address]))
EDIT 2
After some test with the filter parameters.
The NOT operator is still not working so to workaround use "ne" (non-equals)
the example 2 becomes :
https://graph.microsoft.com/v1.0/me/messages/?$orderby=receivedDateTime desc&$filter=(receivedDateTime ge 1900-01-01T00:00:00Z AND contains(subject,'test 1')) AND (from/EmailAddress/address ne [specific address])
UPDATE : OTHER SOLUTION WITH $search
Using $filter is great but it looks like it was sometimes pretty slow. So I found a workaround aboutmy issue.
It's to use AND operator between all terms.
Exemple 4 :
I'm looking for the mails where the subject is test 1;
Let value = "test 1". So you have to splice it by using space separator. And after write some code to manipulate this array, to obtain something like below.
$search="(subject:test AND subject:1)"
The brackets can be important if you use a multiple fields search. And Voilà.

Not sure if it's sufficient for what you're doing, but how about using the contains function within a filter query instead:
https://graph.microsoft.com/v1.0/me/messages?$filter=contains(subject,'Test 1')
Sounds like you're already looking at the doco but here it is just in case.
Update also, this worked for me using the search method:
https://graph.microsoft.com/v1.0/me/messages?$search="subject:'Test 1'"

Related

Regex : findall with a repeated capture group

I would like to understand why :
re.findall(r"(\d[A-Za-z]+)", "My user name is 3e4r 5fg")
returns
['3e', '4r', '5fg']
while :
re.findall(r"(\d[A-Za-z]+)+", "My user name is 3e4r 5fg")
returns
['4r', '5fg']
I tested some combinations with spaces between groups of "digit-letter" and 2 points clearly are involved in :
spaces between those groups
last "+".
I don't really understand why adding "+" after the group changes the result. Can someone explain me the steps of the process which leads to those different answers? Thank you very much.
When you put + after parenthesis you are searching for a pattern that contains one or more sub pattern with 1 digit and (one or more) letters'
so this phrase: "(\d[A-Za-z]+)+" return 2 matches:
3e4r
5fg
When you put a sub-pattern in parenthesis it means that all matches this sub-pattern will enter in a group, the groups is:
3e
5fg
The function re.findall returns only the groups (Unless there are no groups then it returns the matches ).

Regrex query in DB2-LUW

I need a regrex query to match any string having given character. So i tried for example
SELECT wt.CHGUSER FROM "CDB"."WTBALL" wt where REGEXP_LIKE (wt.CHGUSER, '^\d*115*$');
So i am expecting to fetch all the strings having 115 somewhere in between each string. I tried many combinations but i am getting empty column or weird combination.
Are you sure You need a regex? You write "all the strings having 115 somewhere in between each string", but test for a all-digit string with "115" somewhere...
Btw. this could be done also without regex:
WHERE LOCATE('115', wt.CHGUSER) > 0
AND TRANSLATE(wt.CHGUSER, '', '0123456789') --if You really want to test all-digit string
why not use the native "LIKE" expression?
where wt.CHGUSER like '%115%'
This will give different results than your regexp because your expression is looking for '115' so long as there is a digit immediate before and after it. A more generic regexp, which matches your question, would be '.*115.*'
What about -
REGEXP_LIKE (wt.CHGUSER, '^*\d115\d*$');

Tableau Filter Formula

I am trying to filter workgroup name that only contains BL or CL so I used the formula...
STARTSWITH([wrkgrp_shrt_nm], "BL") or STARTSWITH([wrkgrp_shrt_nm], "CL" )
I get the little green check, but when I hit apply it is blank and nothing pulls through
I tried another formula...
if right([wrkgrp_shrt_nm],2) = 'BL' then 1 elseif
right([wrkgrp_shrt_nm],2) = 'CL' then 1 elseif
right([wrkgrp_shrt_nm],2) then 0
end
but I am only getting an error
any suggestions?
If you want "contains", you can just call contains()
contains(wrkgrp_shrt_nm, 'BL') or contains(wrkgrp_shrt_nm, 'CL')
Does the same thing as the find() solution Fred posted, just a little easier to read in this case. I'm not sure why Fred says you cannot use IF. I use IF all the time without problems.
BTW, in case you were wondering, the square brackets around field names are optional if the field name does not include spaces or punctuation, and function names are not case sensitive.
To clarify, you're asking for "contains BL or CL", but your formula specify STARTSWITH which will be true is your field [wrkgrp_shrt_nm] starts with the string "BL" or the string "CL".
If you want "contains", you could use FIND:
FIND([wrkgrp_shrt_nm], 'BL' ) > 0 OR FIND([wrkgrp_shrt_nm], 'CL' ) > 0
You cannot use IF in a condition field, but you can use inline IF (IIF), however it's not necessary in your case.
Edit:
I can totally be wrong with my comment on IF (because I'm still new in Tableau) but I tried IF in a condition field of a filter (as the OP asked) and I can't make it work. I use IF all the time in Calculated Fields however. I'll try again...

Print fields being browsed on the screen

I need to write a FM script which print one field of the records being browsed on the screen and separated by commas.However, I do not know how to select the records being currently browsed and am not able to find it in the documentation (the lack of the good keyword could be the problem).
Thank you!
It sounds like you're trying to create a list of all values for one field in the Found Set. FileMaker 13 introduced the List of Summary type, which makes this pretty easy:
First, create a Summary field, say FoundAddresses. Make it a List of your e-mail address field. This field will contain a return-delimited list of the e-mail addresses in the Found Set.
Second, create a Calculation field, say FoundAddressesCommaDelimited. Make it the following text Calculation:
Substitute (
GetSummary ( FoundAddresses ; FoundAddresses ) ;
¶ ; ", "
)
This will substitute all of the returns in FoundAddresses for comma-space.

regexpression [R] "About 52,883,038 results"

I want to parse an html webpage (Specifically a Google Search Results Page)
Looking for the specific counter string
"About *many results"
where *many can range from 0 to 999,999,999,999 results
grep("About [0-9] results",file)
I can't figure out how to incorporate the range of numbers (including commas) into the regular expression. Can anyone clarify? I've looked for similar questions posted, but their codes do not work for this task.
I'm guessing introduce some kind of wildcard "." but I don't think I'm using it correctly
The structure I had in mind was
Any#Times { { Any#Times( [0-9] ) },}
Solved own question...
didn't have to be fancy at all
"About .* results"
works fine
Depending on the content of the page then your .* works, but could get a very long and incorrect string.
If you want to make sure that you get only numbers, try:
"About ([0-9]+|[0-9]{1,3}(,[0-9]{3})*) results"
I've tested it with grep -E and it'll give you ungrouped numbers:
About 10000000 results
as well as grouped numbers using British/English conventions:
About 100,000 results
but not non-numbers:
About a bajillion results
or badly grouped numbers:
About 100,0 results