code-corps-api icon indicating copy to clipboard operation
code-corps-api copied to clipboard

Elasticsearch implementation

Open paulsullivanjr opened this issue 9 years ago • 8 comments

What's in this PR?

This is currently work in progress. But wanted to get an initial PR out.

References

Fixes #60

paulsullivanjr avatar Jan 22 '17 04:01 paulsullivanjr

Elastix provides basic functionality for working with elasticsearch. It's a pretty small library (4 modules) and not very long or complex.

paulsullivanjr avatar Jan 25 '17 01:01 paulsullivanjr

This looks awesome! Great job. One thing I would suggest is maybe making the field_filter extensible for other fields. Maybe have a map as an input with %{field: "type"} and field_filter is generated from this map so if we want to add multiple fields at once we can. Also, not an elasticsearch expert but I believe just by adding more mapping types we could put other models in the same index so maybe have another layer to the input map with type? Doesnt seem like we need it right now but just a thought. This is definitely a good step forward towards a higher level elixir elasticsearch client!

npendery avatar Jan 27 '17 22:01 npendery

Thanks for the kind words. I like the ideas you proposed and think they should work. I'll start working on those ideas soon.

paulsullivanjr avatar Jan 28 '17 02:01 paulsullivanjr

Hey @paulsullivanjr I just wanted to check in on this and see if there's anything we should be doing here?

joshsmith avatar Mar 10 '17 18:03 joshsmith

@JoshSmith I want to discuss what other steps and pieces we'll need to integrate this. I'll catch up with you on slack tonight or tomorrow. I want to get this done so I can get started other other issues.

paulsullivanjr avatar Mar 10 '17 19:03 paulsullivanjr

Awesome, I will be around to discuss.

joshsmith avatar Mar 10 '17 19:03 joshsmith

Hey @paulsullivanjr just adding that suggestions comment here for context to this PR:

  1. Adding a skills/search endpoint for searching, handled directly in SkillController
  2. Endpoint point needs to return a collection of Skill structures, need to research how to create from elasticsearch results. The Elasticsearch indexes will need to contain the Skill records from the database including id's.
  3. Keep an ELASTICSEARCH_URL in .env

joshsmith avatar Mar 16 '17 17:03 joshsmith

We could easily get Skills back by simply:

  • using results = [%{"id" => 1}, %{"id" => 2}] |> Enum.map(&(&1["id"]))
  • with a where clause: skills = Skill |> where([s], s.id in [1, 2]) |> Repo.all where [1, 2] are the results above

joshsmith avatar Sep 28 '17 06:09 joshsmith