Skip to content

search!#171

Open
aryarm wants to merge 27 commits intomasterfrom
search
Open

search!#171
aryarm wants to merge 27 commits intomasterfrom
search

Conversation

@aryarm
Copy link
Member

@aryarm aryarm commented Feb 24, 2020

What You Need to Do

Everyone needs to run the following commands (in the studycloud folder) after pulling this code:

composer install
php artisan migrate
php artisan cache:clear
php artisan config:cache

If You Want to Use Search (recommended)

If you want to test out the new search feature or plan on using it any time in the future, do the following after the steps above:

  1. Append the following lines to the .env file in your studycloud folder:
    SCOUT_DRIVER=Matchish\ScoutElasticSearch\Engines\ElasticSearchEngine
    ELASTICSEARCH_HOST=localhost:9200
    
  2. Install Elasticsearch, our new search engine
  3. Also make sure to start the search engine every time you want to start using the site:
    1. Check if you've installed the studycloud command by running command -v studycloud
      • If you don't get any output, you'll have to manually start and stop elasticsearch every time you want to start using the search feature
      • Otherwise, if you get a message saying "studycloud", reinstall the studycloud command, so that it can start and stop elasticsearch along with the apache and mysql services:
        • Ubuntu: wget -q https://studycloud.page.link/start -O - | bash -s | xargs -L 1 > ~/.studycloud
        • Mac: curl -skL https://studycloud.page.link/start | bash -s | xargs -L 1 > ~/.studycloud
    2. Make sure to start elasticsearch (either manually or by running the studycloud command) before continuing to the next step
  4. Run php artisan scout:import "App\Resource"

Queuing (optional - not recommended)

You can also do the following to enable queuing of updates to the search results. This is a new feature that will help our server manage a potentially deleterious deluge of update requests. But you don't need to enable it locally if you don't plan on bombarding your computer with such requests.

  1. Append the following line to your .env file:
    SCOUT_QUEUE=true
    
  2. Run the following command every time you want to process queued jobs: php artisan queue:listen or php artisan queue:work
    I recommend adding this step to your studycloud command by editing the ~/.studycloud file.

Summary of Changes in this PR

  1. Updates Laravel from v5.5 to v6.2
  2. Sets up the site to use Elasticsearch, our new search engine
  3. Sets up the site for queuing
  4. Enables search indexing of the Resource model and some of its related data (see 35ffe00 and db5f70d9)
  5. Creates a decent-looking webpage to display the search results
  6. On every page load: runs some JavaScript to enable searching asynchronously

Here's a snapshot of the new search results page:
image

Search Features

The Elasticsearch engine makes our searches incredibly powerful. Here's a sampling of some of its features:

  1. You can specify the fields within which to execute your search. For example, searching for use:Notes will return resources meant to be used as notes. The available fields are:
    name, author, use, classes, contents.name, contents.type, contents.content
  2. You can use the ? and * wildcards.
  3. You can use + and - to specify whether a term must be present or absent.
  4. You can use the AND and OR operators.
  5. You can group search terms using parantheses. For example, the query author:(Ebert OR Koss) will search for resources created by either Ebert or Koss.
  6. You can use tildes ~ to perform fuzzy searches. For example, the query Ebret~ will match Ebert.
  7. You can weight some terms as more important. For example, the query Ebret^2 Koss will make finding resources with Ebret twice as important as finding resources with Koss.
  8. You can use backslashes \ and quotations " to force terms to be interpreted literally.

@aryarm aryarm mentioned this pull request Apr 6, 2020
19 tasks
@aryarm aryarm added dependencies Pull requests that update a dependency file not MVP not minimum viable product php Pull requests that update Php code labels Apr 7, 2020
@aryarm aryarm marked this pull request as ready for review April 13, 2020 02:11
Copy link
Member Author

@aryarm aryarm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should try to fix this before I merge.

I also tested the field weights, and they seem to be fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file not MVP not minimum viable product php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments