Closed shpomp closed 3 years ago
@orhantoy ☀️ Current challenges:
@orhantoy ☀️ Current challenges:
- Placing a subfield (...)
⬆️ Worst case, 1. and 3. could be left unsolved and worked around. A
Thank you very much @orhantoy ❤️ I will work on all of it tomorrow.
Seems like all listed issues are fixed now and all is working. 👯
I realized I that now the search became case-sensitive, which it was not before., As I understand per my efforts in research - because of 'keyword'. Or maybe because I don't quite get where and how to apply the autocomplete in search?
I read through quite a few documents and threads and tried to change the mapping, but of course it did not work 😅 I tried some variations of something like this:
await client.indices.create({
index: index,
body: {
settings: {
analysis: {
analyzer: {
case_insensitive_analyzer: {
type: "custom",
filter: [
"lowercase"
],
tokenizer: "keyword"
}
}
}
},
mappings: {
dynamic: 'strict',
properties: {
fullName: {
type: 'keyword',
analyzer: "case_insensitive_analyzer",
fields: {
autocomplete: {
type: 'search_as_you_type',
},
},
},
email: {
type: 'keyword',
},
},
},
},
});
The case-insensitivity is not a necessity to have but would be nice to understand and, if possible, to fix.
Also, while looking into this, I started thinking if I should introduce wildcard, or even use it instead of keyword (to allow partial string match), but I am sure it is highly likely I just don't understand mapping very well still. 🙏🏽
@orhantoy Thank you once again very much! ❤️ I think it is ready and good to go!
@senner007 @Midnighter Would you like to take a look before the merge? I have added a short description to explain a bit what is going on.
We don't have an elastic account for the project yet (I am using mine, which is on trial, with 2 weeks left). @Midnighter mentioned that Heroku offers an elastic instance, @orhantoy do you think we could/should use that?
Description
Implementing elastic search on a selection of routes:
ES_CLOUD_ID
andES_API_KEY
are placed in .env, allowing to connect and use the elastic database.src/server/config/elastic.js
, the connection to elastic is established and exported (client
). Index name for the index to be created and used is also declared an exported (usersIndex
);src/server/api/lib/utils/syncES.js
, which should be run once withnpm run es:setup
. It creates the index and its mapping in elastic database and copies existing DB users to elastic documents under the created index.Client
andusersIndex
are imported and used inusers.controller
. FunctionsgetUsers
,getUsersByKeyword
,createUser
,deleteUser
are refactored to be replaced or supplemented with elastic functionality.Fixes #124
How to test?
Don't. 🙅🏽
Checklist