Escaping parentheses in contact search API - microsoft-graph-api

I am trying to search for a contact with a phone number of the following format:
(XXX) XXX-XXXX
I tried the following query and get no results:
/v1.0/me/contacts?$top=10&$search="(XXX) XXX-XXXX"
I also tried it with URL encoded parenthesis and also get no results:
/v1.0/me/contacts?$top=10&$search="%28XXX%29 XXX-XXXX"
The only thing that worked for me is:
/v1.0/me/contacts?$top=10&$search="*XXX*XXX*XXXX"
However, with the last one I'm concerned that it could return bad results in some cases where there might be some other numbers in the wildcard positions.
Is there a proper way to do this search?

Have you considered using filter query instead of search, that way you might be able to scope the search just to the phone field.

Related

OR Operator in Google Sheets Not Working?

This is the formula I am working on right now:
=FILTER(Data!A:K, SEARCH("Gretsch", Data!F:F)+SEARCH("Krutz", Data!F:F))
I'm trying to bring in both rows that include "Gretsch" and rows that include "Krutz". Just using one of those instead of both works just fine, and using keywords that the other has included in it's results (for example, searching just Gretsch brings up 10 or so (out of the 100+) products that include "Streamliner" in the F Column, as well as Gretsch, so using this formula:
=FILTER(Data!A:K, SEARCH("Gretsch", Data!F:F)+SEARCH("Streamliner", Data!F:F))
brings up the 10 or so products with both, but I'm looking for one OR the other, so why is that '+' acting like an AND operator instead? Am I just completely off base?
SEARCH returns a number: the starting position where a string is found within another string. It's not a simple 1 like other tests for TRUE, and there is no 0 case (i.e., FALSE) as you have it written. In addition, if either SEARCH does not find the target string, it returns an error; and a number plus an error... returns an error (which is not TRUE and therefore will not be included in the FILTER).
A better approach to achieving OR with FILTER:
=FILTER(Data!A:K, REGEXMATCH(LOWER(Data!F:F),"gretsch|krutz"))
The pipe symbol ("|") means OR in this context, and you may list as many pipe-separated strings as you like. Notice that the search range is wrapped in LOWER and that the terms to search are also lowercase; this assures the same kind of caps-agnostic search you were looking for with SEARCH.
By the way, based on your other recent post, you can also use REGEXMATCH with NOT, e.g.:
=FILTER(Data!A:K, REGEXMATCH(LOWER(Data!F:F),"gretsch|krutz"), NOT(REGEXMATCH(LOWER(Data!F:F),"case")))
One additional note: Your post is tagged "Excel" and "Google Sheets." The formulas I've proposed will only work with Google Sheets. In most cases by far, it is best to tag a post here with either "Excel" or "Google Sheets" but not both, since the differences are substantial between the two.
try:
=QUERY(Data!A:K, "where lower(F) contains 'gretsch'
or lower(F) contains 'krutz'")

Querying lucene index with arbitrary long article text to check for all matches within article (through neo4j)

I'm trying to query the lucene index I've added to a neo4j field (it's a "name" field, that isn't very long, one to ten words at most).
What I do right now is take all the text in a given webpage, sanitize it with a javascript function to keep only words, spaces and alphanumeric characters, and use that to query my index.
.replace(/[^\w\s]|or|and|not|return+/gi, "") // <- escaping the input
I'm not sure if the length of the search text is limited somehow, but results do seem to disappear after about 1050 words (~6500 characters).
Ideally, I'd like to be able to use a couple thousand words in one query, with the end goal of highlighting the matches found within the webpage itself.
Why is my query not returning any results past a certain number of characters ? Am I missing some keyword in my escaping regex ?
Is what I'm trying to achieve feasible ? Is there a better approach I could use ?
Thanks for reading :)
(for anyone finding this, I found a somewhat related question here: Handling large search queries on relatively small index documents in Lucene)

Twitter API - Search latin special characters

How can I perform a search in Twitter API that matches with special chars like Ñ or Ç?
Even web search seems to be confused with those characters
Ex:
https://twitter.com/search?q=u%C3%B1as&src=typd
It returns a list of tweets matching with 'unas' and 'uñas', and the same result is returned if an API search is performed
And it happens in inverse way, if you search 'barca' twitter will return tweets matching with 'barça' and 'barca'
The only way I found to ensure that the keyword, and only the keyword, is in tweets, is a programming filtering when results are fetched. Is there any better way?

Differing search results between Twilio web search and Ruby API helper

I'm getting different results between the searches I run on on twilio.com and the searches I run through the Ruby gem helper.
Here's a sample search:
Here's a search with the same zip code in a Rails console, returning an empty array:
> #twilio_client.account.available_phone_numbers.get('US').local.list({in_postal_code: "19428"})
=> []
These searches were conducted less than a minute apart.
Is this an issue with the REST API, the Ruby helper gem, or my search query?
Ricky from Twilio here.
The code you're using is correct to retrieve phone numbers restricted to a postal code and I can see why you would expect it to match up with the search on Twilio.com. In our search we're actually doing the lookup a bit differently. You can create an experience similar to ours by using a different set of filters to retrieve phone numbers.
#numbers = #client.available_phone_numbers.get('US').local.list(
near_lat_long: '40.6928,-73.9903',
distance: '5'
)
Since phone numbers within a postal code can be sparse we can ensure results by expanding our search to be near the location a user searches for.

Retrieve all hashtags from a tweet

Is it possible using the Twitter API to retrieve a list of all hashtags present within a single tweet?
For example, let's say I have a tweet (let's say it has an ID of 12345) with the following text:
Hi. I love #stackoverflow because it's #superawesome. #fb
Is there an API call that will give me back #stackoverflow, #superawesome, & #fb when I give it an ID of 12345?
Or do I just have to parse the text of the tweet myself?
You'll have to use a regular expression in your language of choice
#\S+
should match any hash, beginning with # and made of a string of characters. It stops at the first space.
If you want to exclude any trailing symbol and have a letter as the last char :
#\S*\w
This expression should work in most of the regex engines I'm aware of.
You can use Tweet Entities. Just include &include_entities=1.
The Twitter API does not have any functions specifically designed for hashtags. You'll need to parse the text on your own.
Although #ialphan's solution is good, if you want to sort hashtags with occurance just use this answer in similar question:
Retrieve all hashtags from a tweet in a PHP function

Resources