Question: For this assignment, you're going to create a fake search engine that's really sponsor friendly. We'll fake the server-side part with static JSON files. The

For this assignment, you're going to create a fake search engine that's really sponsor friendly. We'll fake the server-side part with static JSON files.

The search page mockup is already provided for you in the project repository.

You'll Be Wanting the "Executive" Package

Some search engines have sponsored "results" that companies have paid to put at the top of the page.

Some even used to sneak sponsored results into the normal results and not tell you about it.

All. Chumps.

Why would we ever show results for someone who hasn't paid us?

First, think of three search keywords and create three JSON files. Each of those files will be named for a keyword, and will have a JSON array of 2-3 result objects for that keyword. So for the keyword "cat", you would have a file cat.js, with three results about cats. Each result object has a relevance score, a url, a title, and a brief excerpt from the page. All arbitrary made up stuff. Make sure your excerpts are long enough to need to be cut off when you display them (like a real search result).

We are Number 1! All Others Are Number 2 or Lower.

Now make the "search" page work. When the user hits the search button, make AJAX requests for each keyword in the search. (The behavior here is OR.) If they type "cat", then request cat.js. If they include a word for which there is no file, that shouldn't break anything, there's just no results for that.

Combine the results from the different keywords, sort them by relevance score, and show them on the page (most relevant first). If the search didn't include any of your keywords, insult the user for such a stupid, irrelevant search.

Double Down

Now, make sure that you have at least one result that appears in more than one of the keyword files. Your "search" engine should properly add the scores from both files for that result (e.g. a result from both cats and larvae would get the sum of the scores from both cats.js and larvae.js). Make sure that you sort after you add them.

To be clear, your page must:

  • Use AJAX on each search to retrieve results for each keyword from the server
  • Present them using the mocked-up template
  • Sorted by relevance, summing relevance for results in multiple files
  • The body excerpts should be cut off at some fixed length
  • Insult on failure

Commit and Push regularly!

search.css

.template{display:none;}

.url{font-style:italic;color: green;}

search.html

Search!

Blah, I say

http://blah.blah.blah
Relevance: 0.54
Excerpty. Excerpty. Excerpty. Excerpty. Excerpty. Excerpty. Excerpty.
Excerpty. Excerpty. Excerpty. Excerpty. Excerpty. Excerpty. Excerpty.
Excerpty. Excerpty. Excerpty. Excerpty. Excerpty. Excerpty. Excerpty.
Excerpty. Excerpty. Excerpty. Excerpty...

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!