question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Looking for a way to structure nested or relational data in elastic search

See original GitHub issue

I’m looking for a way to structure nested or relational data in elastic search.

Ex. A cluster of chain restaurants that are separated by regions. But these regions group together locations/addresses is what I had in mind. However this would mean I would have to update the entire document when locations are added or deleted.

I read the following guides and think the best way is to index location/address and then add the name of the restaurant chain to the index document. I’m looking to do a query search one string if possible.

q = 'chipotle san francisco'
s = Search(using=client, index="restaurants").filter("term",name=q)
r = s.execute()

for h in r:
  print h # this would be listing all chipotle restaurants in san francisco area. 

However, the documentation provided here does not say how to persist data with nests or relational data here. What would be the better way to index this sort of structure? I’m not sure if elastic search can do joining like RMDBS. (e.g postgresql) Please advise.

Thanks!

Reference:

https://www.elastic.co/blog/managing-relations-inside-elasticsearch http://stackoverflow.com/questions/23403149/elasticsearch-relationship-mappings-one-to-one-and-one-to-many http://voormedia.com/blog/2014/06/four-ways-to-index-relational-data-in-elasticsearch

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
honzakralcommented, Apr 14, 2016

@rlam3 simpluy pass a score_mode parameter to the has_parent or has_child query:

s = Search()
s = s.query('has_child', score_mode='avg', type='child_type', query=Q('match', title='python'))
0reactions
honzakralcommented, May 7, 2016

Yes, use a has_parent query which will query the children and then you can use it’s score_mode parameter to influence how the parent score will influence the child’s

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing Relations Inside Elasticsearch | Elastic Blog
As an alternative to inner objects, Elasticsearch provides the concept of " nested types". Nested documents look identical to inner objects at ...
Read more >
Briefly describe how to store complex relational data in ...
Briefly describe how to store complex relational data in ElasticSearch. In the traditional database, the description of the data relationship is nothing ...
Read more >
Chapter 8. Relations among documents - Elasticsearch in Action
Some data is inherently relational. ... The nested type makes Elasticsearch index objects as separate Lucene ... Searching in multiple levels of nesting....
Read more >
How to store relational data in elasticsearch - Stack Overflow
Nested Object is a perfect approach for it. There will be no repetition of child objects in parent document if you update the...
Read more >
Choosing the Right Elasticsearch Index Data Structure | Dixa
Nested query allows for searching of nested objects as they are indexed as separate documents. Update, Since you write each entity as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found