Need some help for creating my model

Hello, i am new to elasticsearch and i need some help/hints for creatine my
model. For my relational database ( mysql ) is have the following situation:

Table: Subcategories
Columns: Name, Company

Every subcategory has a name and has a 1:n company relation.

The next is:

Table: Company
Columns: Name, Subcategory

Every company has a name and has a 1:n subcategory relation.

How can i modelling this for elasticsearch. I have a serach form with the
following situation: The user can serach for subcategories, but only one
should shown with have a company assigned. Then you select a subcategory
and omitted the subcategory id. Then only companies should shown which are
assigned to the subcategory.

For some hints i would be very thankfull.

Thanks

Stefan

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/53655a8b-46bc-4c95-8959-61831ac3d1c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

This might help:

Out of the box, you can't model many to many in ES (unless you do it
yourself in code). One to many is supported using either nested or
parent-child.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/159e41dd-32b6-4745-83a0-35f17eda0eda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hello,

many thanks to your answer.
Could you give me a little example how to add/remove a single child to a
parent object, maybe.
I would like to do this with the elasticsearch php module. Is this possible?

Regards Stefan

Am Dienstag, 1. April 2014 16:45:16 UTC+2 schrieb Binh Ly:

This might help:

Elasticsearch Platform — Find real-time answers at scale | Elastic

Out of the box, you can't model many to many in ES (unless you do it
yourself in code). One to many is supported using either nested or
parent-child.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3ff28df3-39ca-4e3c-b678-8c49f631473d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

hm, a little example would be nice. I dont get it to run. Thanks-

Am Mittwoch, 2. April 2014 12:11:04 UTC+2 schrieb Stefan Kruse:

Hello,

many thanks to your answer.
Could you give me a little example how to add/remove a single child to a
parent object, maybe.
I would like to do this with the elasticsearch php module. Is this
possible?

Regards Stefan

Am Dienstag, 1. April 2014 16:45:16 UTC+2 schrieb Binh Ly:

This might help:

Elasticsearch Platform — Find real-time answers at scale | Elastic

Out of the box, you can't model many to many in ES (unless you do it
yourself in code). One to many is supported using either nested or
parent-child.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0f0bbe95-b95d-4e3c-9434-060fe30a9e0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

So assuming you want parent/child (assuming you already set up the mapping
correctly), to add a child to a parent:

curl -XPOST localhost:9200/test/child/child1?parent=parent1 -d'
{
"state" : "Ohio"
}'

To delete the above child:

curl -XDELETE localhost:9200/test/child/child1

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/9900330b-f1e3-432f-9e0b-5621d16899cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Binh Ly,

thanks for answer, That helped me a lot. But how can i use the same queries
with the PHP API? I need to add the parent query, but i dont find anything
about this in the docu.

Thanks for helping and sharing your time.

Regards Stefan

Am Freitag, 4. April 2014 22:27:51 UTC+2 schrieb Binh Ly:

So assuming you want parent/child (assuming you already set up the mapping
correctly), to add a child to a parent:

curl -XPOST localhost:9200/test/child/child1?parent=parent1 -d'
{
"state" : "Ohio"
}'

To delete the above child:

curl -XDELETE localhost:9200/test/child/child1

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/30641aa3-02bf-4d82-9d50-331171c3d3d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Maybe a short answer how i can use it with the php api? :slight_smile: 1000 times thank
you, Stefan

Am Freitag, 11. April 2014 10:18:07 UTC+2 schrieb Stefan Kruse:

Hi Binh Ly,

thanks for answer, That helped me a lot. But how can i use the same
queries with the PHP API? I need to add the parent query, but i dont find
anything about this in the docu.

Thanks for helping and sharing your time.

Regards Stefan

Am Freitag, 4. April 2014 22:27:51 UTC+2 schrieb Binh Ly:

So assuming you want parent/child (assuming you already set up the
mapping correctly), to add a child to a parent:

curl -XPOST localhost:9200/test/child/child1?parent=parent1 -d'
{
"state" : "Ohio"
}'

To delete the above child:

curl -XDELETE localhost:9200/test/child/child1

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c1761a0d-7470-477e-ae78-97773051f47b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ok new try. Is it general possible to do this with the PHP API, i dont find nothing in the docu. Maybe i dont see it. Regards Stefan

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/deb41747-30d3-4e48-8bb3-86f861020560%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.