Commit Graph

27 Commits

Author SHA1 Message Date
Mahmudul Haque
62fa7b9350 unparam lint (#16927)
* fix "always receives ..." lint err

* add unparam lint check

* fix failed test

* rm details param

* ignore unparam lint

* magic string replaced with model.NewRandomString

* rm unused enableComplianceFeatures param

* generate random message inside createPost

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-16 12:48:20 +05:30
Agniva De Sarker
9992a27a90 Revert "MM-24530-Add support for search terms with underscore using postgresql engine (#16618)" (#16950)
This reverts commit ba3b788e46.
2021-02-17 13:52:15 +05:30
Mahmudul Haque
2b038db6ad unparam lint (#16901)
Automatic Merge
2021-02-12 10:22:27 +01:00
Jesús Espino
0e9ad9f7f8 Replacing {require,assert}.{Nil,NotNil} with {require,assert}.{NoError,Error} in the store tests (when comparing errors) (#16886)
* Replacing require.Nil with require.NoError

* More replacements

* More Nil/NotNill to NoError/Error

* Other detected errors

* renaming apperr to err

* Removed not needed line

* Rename old appErr variables that are no longer model.AppError values

* Fixing tiny typo

* Reverting changes outside the store (accidentally added)

* Apply suggestions from code review

Co-authored-by: Doug Lauder <wiggin77@warpmail.net>

Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
2021-02-10 11:34:41 +01:00
Antwi Gambrah
ba3b788e46 MM-24530-Add support for search terms with underscore using postgresql engine (#16618)
* add support for search terms with underscore using postgresql

* fix failing tests

Initially issue fix applied to all search terms instead of the ones that contains _

* direct cast tsquery

* fix test issues

* refactor underscored quoted term search

* support search term case-insensitive

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-20 00:10:10 +05:30
Jesús Espino
2a63b5552a Add search engine support for files (#16190)
* Add search engine support for files

* Fixing i18n

* Fix golangci-lint

* Fix consistency problem in the Search receiver functio of the SqlFileStore

* Fixing some tests

* Fixing test

* Apply suggestions from code review

Co-authored-by: Mario de Frutos Dieguez <mario@defrutos.org>

* Addressing PR review comments

* Removing some empty lines

* Address PR review comments

* Fixing problem after merge master

* Fixing spelling problem

* Add missed translations

* Fixing certain global variable usages after merge master

* Fixing some constants usage

* Fixing goimports order

Co-authored-by: Mario de Frutos Dieguez <mario@defrutos.org>
2021-01-11 15:14:16 +01:00
Agniva De Sarker
e89b26e8f3 goimports (#16640)
* format using `goimports -local github.com/mattermost/mattermost-server/v5 -w`

* added goimports lint check to .golangci.yml

* format using `goimports -local github.com/mattermost/mattermost-server/v5 -w` for a corner case

* make app-layers, *-mocks and store-layers for ci check

Co-authored-by: Mahmudul Haque <mahmudulhaque@protonmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-07 22:42:43 +05:30
Agniva De Sarker
c1dd23a3c8 MM-31063: Change constants to use CamelCase (#16608)
* MM-31063: Change constants to use CamelCase

* store package

* change allcaps to camel case (#16615)

* New tools.mod

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2021-01-04 11:32:29 +05:30
SimonSimonB
8b6ac5f5d2 Removed AppError from searchlayer/user_layer.go (#16532)
Automatic Merge
2021-01-04 05:45:17 +01:00
Choo Jia Le
ccf5916ef0 [MM-24337]: Fix the team and channel filtering UT to include empty team or channel (#15912)
* Fix the team and channel filtering UT to include empty team or channel

* Fix tests that were failing before this change

Once we've activated the team/channels filter tests for PostgreSQL
and MySQL there are some tests failing so this changes fixes them

* Disable team filtering tests for DBs by now

We have a discrepancy between DB search and ES/Bleve on how to filter
teams when you have users in both teams:

  - DB when filtering by one team and searching by another returns users that are in both teams
  - Bleve and ES returns empty

Co-authored-by: Mario de Frutos <mario@defrutos.org>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-11-05 12:45:41 +01:00
Miguel de la Cruz
1d2220141e [MM-26420] Adds wildcard support to Bleve (#14885) 2020-09-18 10:49:56 +02:00
Rodrigo Villablanca
54f86e7fb1 Migration of TeamStore Part 1 (#15246)
Automatic Merge
2020-09-03 00:29:57 -04:00
Abdulkadir Poyraz
f12ca27bac [MM-24522] remove duplication in OR and IncludeDeletedChannels params for search (#14573) 2020-08-31 13:40:58 +02:00
Rodrigo Villablanca
6a50106cd9 Filter stop words when searching posts in mysql (#14509) 2020-08-21 17:58:17 +02:00
Amarjeet Anand
fb453d578f [MM-24526] Filter * characters from the search terms in DB (#14884) 2020-08-05 13:43:31 +02:00
Miguel de la Cruz
df943fbf91 [MM-26397] Take query size and order into account for Bleve (#14882)
* [MM-26397] Take query size and order into account for Bleve

* Add a test to check post search pagination

* Add tests for checking limit when searching users

* Make pagination an independent test to discriminate DB engines
2020-06-30 15:38:58 +02:00
Mario de Frutos Dieguez
bec2f366a7 [MM-24334] Include role filtering in ES search (#14465)
* ES supports role filtering for users

- Added roles field for ES user index
- Include role filtering logic in ES
2020-06-29 21:24:36 +02:00
Mario de Frutos Dieguez
4c33b7a35d [MM-25767] Quick switch users search is always falling back to the database (#14762)
* Refactor of getListOfAllowedChannelsForTeam

Also, I've fixed some problematic scenarios:

- The quick search doesn't provide team id so it was always failing
- When the teamId was empty and view restrictions too we always
  return all the channels because if we do "strings.Contains("foo", "")
  it always returns true
- There was a case, in quick search with a guest account, where you
  get an empty result because teamId is not provided

* Error if team id is not passed when searching for the channel

If we search users passing the channel id, we must pass the team id
too so we avoid returning all the channels if we remove the empty
team id restriction we have in the getListOfAllowedChannelsForTeam

There is no known reason to search for a channel but not filtering
using the team id. Even guest accounts belong to a team
2020-06-26 20:37:35 +02:00
Mario de Frutos Dieguez
e7aaf0ea6a Activate tests about search terms inside links (#14578) 2020-06-23 16:15:41 +02:00
Mario de Frutos Dieguez
0a96ed04a3 ES now supports inactive users filtering (#14463)
* ES now supports inactive users filtering
2020-06-18 21:17:35 +02:00
Rodrigo Villablanca
6f28f3526d Migrate PermanentDelete method from ChannelStore to return error inte… (#14706)
Automatic Merge
2020-06-06 11:47:18 +02:00
Mario de Frutos Dieguez
f135e6c1bf [MM-24453] Sanitize user term search (#14494)
* Sanitize user term search

Remove the @ at the beginning of the search term in order to
make it possible for ES to return results
2020-05-24 10:50:07 +02:00
Miguel de la Cruz
0154b8059b [MM-20979] Add first implementation of the Bleve search engine (#14562)
* [MM-20979] Add first implementation of the Bleve search engine

* Fix i18n

* Migrate searchengine utils tests

* Fix linter

* Don't add allTermsQ if both termQueries and notTermQueries are empty

* Fix test that should work if user is system admin

* Modify naming according to review comments

* Abstract getIndexDir function

* Extracting bleve engine name as a constant

* Merge both Indexer interfaces into one

* Add worker stopped message

* Allow worker to be started/stopped with config change

* Use constants for index names

* Modify test order

* Fix linter

* Trying to unlock the CI
2020-05-20 01:29:55 +02:00
Agniva De Sarker
53cc7a26ea MM-24133: Migrate AppError from bot_store.go (#14339)
* MM-24135: Migrate AppError from SaveChannel/channel_store.go

This is the first POC of migration of store app errors to plain error.

We create a few basic error types in the store package and use
them to return the errors from store methods. In the app layer,
we inspect the error and re-create the exact app errors. This lets
us preserve the same error content, but yet move to plain errors.

Since this is a gradual migration, this means that the error inspection
code will be duplicated across the app layer whenever a store method
is invoked. But all of that should go away once we start propagating
the errors higher up the hierarchy.

There have been a significant amount of changes in the storetest and searchtest
layer, primarily because we have to rename the err variable now that it is of
a different type.

* Addressed review comments

* MM-24132: Migrate AppError from SaveDirectChannel/channel_store.go

This PR migrates 2 new methods SaveDirectChannel and CreateDirectChannel
to return error instead of AppError.

We also need to handle the error internally in SaveMultipleMember for now
until that is migrated too.

* MM-24133: Migrate AppError from bot_store.go

* Fix errors

* Fix err

* Fix bad return

* Fix vet errors

* Fix incorrect error check

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-19 08:36:53 +05:30
Agniva De Sarker
729a84a3e6 MM-24135: Migrate AppError from SaveChannel/channel_store.go (#14299)
* MM-24135: Migrate AppError from SaveChannel/channel_store.go

This is the first POC of migration of store app errors to plain error.

We create a few basic error types in the store package and use
them to return the errors from store methods. In the app layer,
we inspect the error and re-create the exact app errors. This lets
us preserve the same error content, but yet move to plain errors.

Since this is a gradual migration, this means that the error inspection
code will be duplicated across the app layer whenever a store method
is invoked. But all of that should go away once we start propagating
the errors higher up the hierarchy.

There have been a significant amount of changes in the storetest and searchtest
layer, primarily because we have to rename the err variable now that it is of
a different type.

* Addressed review comments

* Made all appError origins to be CreateChannel

* Remove typed internal error

* Fix translations

* fix layer generation

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-05-12 21:23:41 +05:30
Mario de Frutos Dieguez
9853056b7a Implementation of expectation tests (#14191) 2020-04-27 21:54:46 +02:00
Miguel de la Cruz
4fe25b1cdd [MM-21551] Add search tests structure to test the search engines (#14031)
* WIP

* Adding bleve to go modules

* WIP

* Adding missing files from searchengine implementation

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* User and channel indexing and searches implemented

* Make bleve tests run with in-memory indexes

* Implement post index and deletion tests

* Initial commits for the search layer

* Removing unnecesary indexing

* WIP

* WIP

* More fixes for tests

* Adding the search layer

* Finishing the migration of searchers to the layer

* Removing unnecesary code

* Allowing multiple engines active at the same time

* WIP

* Add simple post search

* Print information when using bleve

* Adding some debugging to understand better how the searches are working

* Making more dynamic config of search engines

* Add post search basics

* Adding the Purge API endpoint

* Fixing bleve config updates

* Adding missed file

* Regenerating search engine mocks

* Adding missed v5 to modules imports

* fixing i18n

* Fixing some test around search engine

* Removing all bleve traces

* Cleaning up the vendors directory and go.mod/go.sum files

* Regenerating timer layer

* Adding properly the license

* Fixing govet shadow error

* Fixing some tests

* Fixing TestSearchPostsFromUser

* Fixing another test

* Fixing more tests

* Fixing more tests

* Removing SearchEngine redundant text from searchengine module code

* Fixing some reindexing problems in members updates

* Fixing tests

* Addressing PR comments

* Reverting go.mod and go.sum

* Addressing PR comments

* Fixing tests compilation

* Fixing govet

* Adding search engine stop method

* Being more explicit on where we use includeDeleted

* Adding GetSqlSupplier test helper method

* Mocking elasticsearch start function

* Fixing tests

* Search tests

* Fix tests

* Fix mod

* Fixing searchEngine for test helpers with store mocks

* Remove loglines

* Fix i18n strings

* Migrate search posts tests

* Fix linter

* Do not run search tests if -short flag is enabled

* Migrate back store tests that didn't belong to the searchlayer

* Fix scopelint issues

Co-authored-by: Jesús Espino <jespinog@gmail.com>
2020-03-30 19:17:40 +02:00