Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expression operator testing whether a string contains a substring #4113

Closed
lucaswoj opened this issue Feb 1, 2017 · 9 comments · Fixed by #8876
Closed

Add expression operator testing whether a string contains a substring #4113

lucaswoj opened this issue Feb 1, 2017 · 9 comments · Fixed by #8876
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏
Projects

Comments

@lucaswoj
Copy link
Contributor

lucaswoj commented Feb 1, 2017

From @vicapow on April 5, 2016 22:46

This would be useful for showing query results as the user types.

Copied from original issue: mapbox/mapbox-gl-style-spec#438

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Feb 1, 2017

Closely related to #233

@1ec5
Copy link
Contributor

1ec5 commented Oct 26, 2017

Now that expressions have landed and can be used as filters, this is actually a request to add an expression operator. Specifically, there should be an operator that tests whether a string contains another string.

By analogy, the most likely syntax would be ["match", needleString, haystackString]. However, the word “match” is more closely associated with wildcards and regular expressions, which are covered by #4089. As I mentioned in #5226 (comment), in Objective-C and Swift, NSPredicate has a CONTAINS operator that serves as both an array search operator and a substring search operator (#4113), depending on the type of the first argument. It’s a convenient option even when a MATCHES operator exists for regular expressions.

@1ec5 1ec5 changed the title Add "substring" feature filters Add expression function testing whether a string contains a substring Oct 26, 2017
@1ec5 1ec5 changed the title Add expression function testing whether a string contains a substring Add expression operator testing whether a string contains a substring Oct 26, 2017
@arethasamuel
Copy link

Hi When will this feature be ready? autocomplete search is one of our main use cases, is there an alternative way of doing a "contains" search?

@andrewharvey
Copy link
Collaborator

@arethasamuel if your data isn't too big you could keep an external list of the query properties from your features and filter based on the full list of names which match the user input.

@anandthakker
Copy link
Contributor

@arethasamuel the best place to track this at the moment is via the discussion about regexp expressions happening at #6228. As you can see from that conversation, we're still hashing out the right API design, so there's no concrete timeline for when this functionality will be available.

@pshavr
Copy link

pshavr commented Dec 2, 2018

so
when substr?)

@dwohlfahrt
Copy link

I'll second @pshavr 's request for a substring function and associated expression syntax!

@1ec5
Copy link
Contributor

1ec5 commented Oct 3, 2019

A substring test expression would make it easy to implement these road maps color-coded by street name suffix in GL.

@ryanhamley
Copy link
Contributor

A substring test expression would make it easy to implement these road maps color-coded by street name suffix in GL.

Here's an example of the color-coded road maps mentioned by @1ec5
https://jsfiddle.net/rsh412/Ldn39w0x/4/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏
Projects
Expressions
  
Done
Development

Successfully merging a pull request may close this issue.

9 participants