Dr.Kameleon
Dr.Kameleon

Reputation: 22820

Database design and Elastic Search

DISCLAIMER: I've never been a DB guru. And I'm only getting started with Elastic Search. :)


I'm creating a Dictionary-type Database.

In MySQL terms, I'd have a table of "Words", like this:

|-------------------
| Words
|-------------------
| id
| name
| part_of_speech
| language
|-------------------

And a table of "Translations", linking words together like:

|-------------------
| Translations
|-------------------
| word_a_id
| word_b_id
| sense
|-------------------

How could that be migrated to Elastic Search?

I have created an index dictionary with a type word.

How could I set a translations table and still keep the references to the existing "words" ? Am I missing something conceptual?

Upvotes: 0

Views: 605

Answers (1)

Ashalynd
Ashalynd

Reputation: 12573

ElasticSearch is conceptually document-based, not relation-based. One possible way to achieve what you want would be to create "translation" index, where every entry would contain a set of nested "word - POS - language" pairs and a "meaning" field. Then you could search this index for every entry containing a given word.

Alternatively, you could consider "word" a child document of a "translation". That would be more similar to your current approach. In ElasticSearch, you would have to look up the parent translation of the given word, and then to make another call to find a child word for that translation that belongs to the given language.

I can't tell if this is the most useful translation approach though, because words have multiple meanings and for different languages they don't completely overlap, but that is a different topic.

Upvotes: 1

Related Questions