Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Add ability to search for a single item #296

Closed
4 tasks done
emroussel opened this issue Aug 24, 2017 · 2 comments
Closed
4 tasks done

Add ability to search for a single item #296

emroussel opened this issue Aug 24, 2017 · 2 comments
Assignees
Labels

Comments

@emroussel
Copy link
Collaborator

emroussel commented Aug 24, 2017

As a user,
I want to be able to find an item by searching for its brand or model
so that I can find it more easily.

  • Research how to implement search with MySQL
  • Pass through search criteria from "get all" request as a parameter
  • Add search method to database service
  • Document query parameters for search on "get all" requests
@AdamVig AdamVig mentioned this issue Sep 25, 2017
4 tasks
@AdamVig AdamVig added this to the October 9 Sprint milestone Sep 26, 2017
@AdamVig AdamVig self-assigned this Sep 26, 2017
@AdamVig AdamVig removed this from the October 9 Sprint milestone Oct 9, 2017
@AdamVig
Copy link
Collaborator

AdamVig commented Oct 19, 2017

The useful searchable fields are brand and model. Barcode and category are not currently displayed in the inventory list, so it would be confusing if the search bar showed results for those two pieces of data.

There are two ways I could implement this.

First, MySQL supports full-text search (though Knex.js only supports it via .raw functions). This approach wouldn't work in this specific instance, however, because the item table does not have any textual fields to search (other than barcode, which the average user would not be searching for). I could make a view containing all the textual data related to items, but it is impossible to create fulltext indexes on views.

It might be possible to change the name columns in brand and model to full-text indexes, then to use the match againstsyntax to search them in query where they are joined with the item table. This is worth looking into. Tutorial on full-text searches in MySQL.

Second, MySQL supports the LIKE operator for fuzzy searches in where clauses. Knex.js has good support for it as well. This would work well for this simple use case, but may not be as performant or scale as well as the match against approach.

@AdamVig
Copy link
Collaborator

AdamVig commented Oct 22, 2017

The implementation of this feature shows the value of #373 (Refactor endpoint service) because it involves adding yet another optional parameter to endpoint.getAll that is passed through to the db service.

In this case, there is some logic implemented in the endpoint service before the parameter is passed to the db service, but that could also be implemented with a simple service method called by the endpoint itself before passing the search to the db service.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants