i'm creating a Car Dealer web-site. And i'm trying to use elasticsearch for my search. But i dont understand relationships in elasticsearch. i have Cars
, Car_Options
, Brand
, City
tables. i'm keeping some meta-datas in Car_Options
table. normally in mysql my tables like :
Car Table :
id , name , brand_id , price , city_id
Car_Options Table :
id , car_id , name , value
Brand Table :
id , name
City Table :
id , name
i tried to use this package for elasticsearch : iverberk/larasearch. I can index my Cars table (Model) and i can search on this table. But i could not understand how to fetch related datas from other tables. i read about relations on elasticsearch , but i could not implement it. Some of them tells about indexing them to one document. some of them tells about parent/child way. So , my problem is , i dont understand how to index relations on elastic search and how to search them.
i indexed Cars and Cites to try but i could not get to true result. i made some tries like :
return Car::search('NewYork', ['fields' => ['city.name']])->getResults();
Waiting for help about logic ! which way i should follow ? how should i index them with relations ?
Thank you !
The power of a NoSQL database like ElasticSearch is that nobody makes you do complicated realtions to avoid duplicate data.
This means that, personally, if the only thing you need to store in the car model is a city name, just save it there.
I really think it's quicker and more efficient to duplicate some data than to make 2 calls, one for Car model and another one for the related City.