drde3456 2015-06-06 11:05
浏览 52

Laravel上的弹性研究关系

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 !

  • 写回答

1条回答 默认 最新

  • dpu66046 2015-06-06 11:32
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度