Use the search index for the search resource when available

Review Request #9116 - Created Aug. 2, 2017 and submitted

Barret Rennie
Review Board
release-3.0.x
9105, 9115
reviewboard

When indexing is enabled, we can use it to perform better full text
search for review requests and users. Since review groups are not
indexed, we still have to query the database for them even if search is
enabled. This does have the side effect that review requests published
by a user will show up in a search for that user's username, but that is
a convenient benefit.

Ran unit tests.

  • 0
  • 0
  • 16
  • 0
  • 16
Description From Last Updated
Barret Rennie
Christian Hammond
  1. 
      
  2. Typo in the description: "databse"

  3. reviewboard/search/testing.py (Diff revision 2)
     
     

    I know the name existed before, but can we call this reindex_search or something, just so it's a little bit more clear in call sites?

  4. reviewboard/search/testing.py (Diff revision 2)
     
     

    , optional

  5. reviewboard/search/testing.py (Diff revision 2)
     
     
     
     
     
     
     
     
     
     

    Do tests depend on these settings after using this context manager? Other tests will already reload the siteconfig, and you shouldn't need to re-fetch the siteconfig, so I think you can basically just set the keys and save.

  6. reviewboard/webapi/resources/search.py (Diff revision 2)
     
     
     
     

    haystack.inputs is in the wrong import group.

  7. reviewboard/webapi/resources/search.py (Diff revision 2)
     
     

    Rather than have this function, which just appears to be serializing content the right way from the search functions, can we just return the right data from the beginning in those functions?

  8. reviewboard/webapi/resources/search.py (Diff revision 2)
     
     
     

    No need for the else. I'd instead say we should have comments within the if above saying that if search is enabled, we'll be making use of the search index for results, and one below the whole new block, explaining that we're falling back to using more restrictive database lookups. It'll help when reading the code.

    Same comments apply below.

  9. reviewboard/webapi/tests/test_search.py (Diff revision 2)
     
     
     
     
     

    Only one blank line.

  10. reviewboard/webapi/tests/test_search.py (Diff revision 2)
     
     
     

    Trailing newline.

  11. 
      
Barret Rennie
Review request changed

Change Summary:

Addressed Christian's feedback.

Description:

   

When indexing is enabled, we can use it to perform better full text

    search for review requests and users. Since review groups are not
~   indexed, we still have to query the databse for them even if search is
  ~ indexed, we still have to query the database for them even if search is
    enabled. This does have the side effect that review requests published
    by a user will show up in a search for that user's username, but that is
    a convenient benefit.

Depends On:

+9105 - Move Review Board's search to a SearchForm + generic SearchView

Diff:

Revision 3 (+221 -45)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

Barret Rennie
Review request changed

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

Barret Rennie
David Trowbridge
  1. 
      
  2. reviewboard/search/forms.py (Diff revision 5)
     
     

    There's an extra newline here that doesn't make sense. Or perhaps the comment should be moved above FILTER_TYPES?

  3. reviewboard/webapi/resources/search.py (Diff revision 5)
     
     

    The "however" is awkward. How about just "If search is disabled"

  4. reviewboard/webapi/resources/search.py (Diff revision 5)
     
     

    Same here.

  5. 
      
Barret Rennie
David Trowbridge
  1. Ship It!
  2. 
      
Barret Rennie
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.0.x (2e24fa1)
Loading...