It All Started with a Question about Mapping and Filters - Montana Webmaster

It All Started with a Question about Mapping and Filters

The Starting Question

Photo of oil filters and oil
It all started with a question about filters

“Do search bars use mapping methods to filter the data on the web to narrow down what your looking for?”

The first part of this article demonstrates the skill of asking and answering a technical question.

Following the Wrong Stream of Thought

Wrong Understanding 1: Geographic maps
Remembering a project that involved custom programming for a specialized Google Map for tracking wildlife, I went down the wrong stream and answered the wrong question. I was also following the wrong stream because Google Search often includes Google Maps in the result.

Wrong Understanding 2: Which meaning of “method”
I should have stopped at the word “method” which is uniquely Java in coding, but which has other meanings in the process and training arenas. But, the word “method” also has a more general meaning.

Wrong Understanding 3: Mapping methods
Now we have two words to interpret. After some thought, I got the “mapping” correct in that it means matching a word in one system to a word in another system. But, I got it wrong in that I interpreted it to mean methods of using a search engine by thinking of words with similar meanings.

The wrong answer
“I still use a plain ole Google search, although, it’s definitely filling up with junk, like social media feeds.” There are no Java Dependencies in that answer.

Starting with a Filter Method for a Search Bar

The reply to my answer put the question into the right context: “No for instance if I were to make a filter method for a search bar. I would need to use the .map() array method, right?”

In thinking about the answer, my first thought is to look at the bigger picture and wonder what the search bar is searching: a database? text files? code? You can’t have a filter unless you have a dataset to filter. Does the dataset make a difference here? I’m not sure. But, either way, I don’t have that information. The information I have is that this is a Java question.

Isolating the idea of filtering, I still don’t have enough information. At its simplest form, if the data to be filtered is character-based, I would do a simple string search on the normal single search field. So, now I need to rethink the technology. Where does the term “filter” fit in? It took several search strings in Google to find a good definition, but this was helpful: “An extension of faceted search, a search filter is a specific attribute a visitor can use to refine the search results of a particular product listing page, e.g. by size, color, price, or brand.” Now, we are no longer in playing with string searches, but with specific field searches where a viewer can choose the fields. So, those additional fields in the search need to be mapped to the data source.

So What is .map()?

There are two things to consider here 1) is this related to a type of function that is common in programming, 2) does this code, and question, only apply to a specific language, and project?

A search on “what is a mapping function in programming” results in the first item being an article about mapping in Python, and there is a link to an article about .map() in JavaScript. Changing the search terms show that mapping functions are available in other languages, as well. So, it seems that in #1 mapping is a common function in programming. For question #2, we see that we are looking at a question about JavaScript. It looks very similar in Java, but there is no period in front. The reason that there is a period in front in JavaScript is that it’s part of a larger set of code:

The word “map” is ambiguous in that it could seem like a function to put items on a geographic map, but it’s not. Mapping is an action that is common in programming languages when data from one type of structure has to be lined up with data to populate another type of structure. For example, if you are moving data from a website form to a database, the data has to be mapped from the form fields to the correct table and fields in the database.



  1. Definition of Search Filter
  2. Java 8 Mapping


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.