Plots2: Existing tags not showing up as an exact match in search bar autosuggestions

Created on 12 May 2021  ·  3Comments  ·  Source: publiclab/plots2

Please describe the problem (or idea)

What happened just before the problem occurred? Or what problem could this idea solve?

Not quite a bug, but more of an observation that I didn't realize was limiting the results I'd see when using the search bar: when previously searching for mapping content, I entered mapping into the search bar, and that tag didn't appear in the autosuggested list of tags (see screenshot). But today I saw the mapping tag on a post and clicked on it, and saw from the tag page that there's quite a lot of content there tagged with mapping!

mapping results

What did you expect to see that you didn't?

I expected to see mapping appear in the autosuggested list of tags as an exact match when entering that term into the search bar, given that the mapping tag page exists and there's lots of content attached to that tag.

Please show us where to look

Existing content with the mapping tag: https://publiclab.org/tag/mapping

What's your PublicLab.org username?

bhamster

add-code-links discussion enhancement help wanted

Most helpful comment

Hi @bhamster07 thank you for a very clearly documented observation and idea! ✨

I'm going to try to tease out some details here to help. My questions:

  1. what is the current sorting?
  2. where in the code would we be able to insert an exact match to add it to the results?
  3. would it cause any slowdown to add a 2nd query? (autocompletes are very latency sensitive for the user - we want it to be as fast as possible)
  4. do we need to worry about filtering it out of the remaining results once we add it at the top? (this seems easy so why not)
  5. would adding the exact match at the top result in any other features on the site getting affected? (i.e. do we use this matching generator for other purposes where we don't want this modification?)

OK, so to 1) i see this endpoint where we're responding to autocompletion: https://publiclab.org/tag/suggested/mapping (only accessible via JavaScript):

https://github.com/publiclab/plots2/blob/158fadc6ed12b66bd0b17f65a134cef59b81cfee/app/controllers/tag_controller.rb#L394-L401

Note this is different from the tag autocompletion in the search box on https://publiclab.org/tags, which is from this segment of code.

As to 5) i want to cautiously say the only other place we're using this code is on https://publiclab.org/search/tags

I think that means we could insert the exact match at the top of the list in this deeper API code:

https://github.com/publiclab/plots2/blob/158fadc6ed12b66bd0b17f65a134cef59b81cfee/app/services/search_service.rb#L79-L91

I'd like also to write a functional test for this to confirm that the top match is the exact match. I think this would be based on this test, and follow it, using an entire word like "spectrometer":

https://github.com/publiclab/plots2/blob/3a05ae2d547c71d5a7d173741586397947fcbc00/test/functional/tag_controller_test.rb#L435-L440

This is great because for the partial match we'd still see this ordering:

https://github.com/publiclab/plots2/blob/3a05ae2d547c71d5a7d173741586397947fcbc00/test/functional/tag_controller_test.rb#L439

But in the exact match we'd see items 1 and 2 swap places. That should be a great and specific test.

I want to propose adding this to the Tagging project for our combined Outreachy and GSoC teams! cc @17sushmita @Manasa2850 (more soon on how your project plans may overlap! 🎉)

All 3 comments

Thanks for opening your first issue! This space is protected by our Code of Conduct - and we're here to help.
Please follow the issue template to help us help you 👍🎉😄
If you have screenshots or a gif to share demonstrating the issue, that's really helpful! 📸
Do join our Gitter channel for some brainstorming discussions.

Hi @bhamster07 thank you for a very clearly documented observation and idea! ✨

I'm going to try to tease out some details here to help. My questions:

  1. what is the current sorting?
  2. where in the code would we be able to insert an exact match to add it to the results?
  3. would it cause any slowdown to add a 2nd query? (autocompletes are very latency sensitive for the user - we want it to be as fast as possible)
  4. do we need to worry about filtering it out of the remaining results once we add it at the top? (this seems easy so why not)
  5. would adding the exact match at the top result in any other features on the site getting affected? (i.e. do we use this matching generator for other purposes where we don't want this modification?)

OK, so to 1) i see this endpoint where we're responding to autocompletion: https://publiclab.org/tag/suggested/mapping (only accessible via JavaScript):

https://github.com/publiclab/plots2/blob/158fadc6ed12b66bd0b17f65a134cef59b81cfee/app/controllers/tag_controller.rb#L394-L401

Note this is different from the tag autocompletion in the search box on https://publiclab.org/tags, which is from this segment of code.

As to 5) i want to cautiously say the only other place we're using this code is on https://publiclab.org/search/tags

I think that means we could insert the exact match at the top of the list in this deeper API code:

https://github.com/publiclab/plots2/blob/158fadc6ed12b66bd0b17f65a134cef59b81cfee/app/services/search_service.rb#L79-L91

I'd like also to write a functional test for this to confirm that the top match is the exact match. I think this would be based on this test, and follow it, using an entire word like "spectrometer":

https://github.com/publiclab/plots2/blob/3a05ae2d547c71d5a7d173741586397947fcbc00/test/functional/tag_controller_test.rb#L435-L440

This is great because for the partial match we'd still see this ordering:

https://github.com/publiclab/plots2/blob/3a05ae2d547c71d5a7d173741586397947fcbc00/test/functional/tag_controller_test.rb#L439

But in the exact match we'd see items 1 and 2 swap places. That should be a great and specific test.

I want to propose adding this to the Tagging project for our combined Outreachy and GSoC teams! cc @17sushmita @Manasa2850 (more soon on how your project plans may overlap! 🎉)

Thanks so much for building this issue out with all these details @jywarren ! 😄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

first-timers[bot] picture first-timers[bot]  ·  3Comments

first-timers[bot] picture first-timers[bot]  ·  3Comments

keshavsethi picture keshavsethi  ·  3Comments

milaaraujo picture milaaraujo  ·  3Comments

divyabaid16 picture divyabaid16  ·  3Comments