[英]Search/retrieve by a large OR query clause with Solr or Elasticsearch
I have a search database of car models: "Nissan Gtr", "Huynday Elantra", "Honda Accord", etc... 我有一个汽车模型的搜索数据库:“日产Gtr”,“ Huynday Elantra”,“ Honda Accord”等。
Now I also have a user list and the types of cars they like user1 likes: carId:1234, carId:5678 etc... 现在我还有一个用户列表,以及他们喜欢user1喜欢的汽车类型:carId:1234,carId:5678等...
Given user 1 I would like to return all the cars he likes, it can be 0 to even hundreads. 给定用户1,我想退回他喜欢的所有汽车,它可以是0甚至是杂项。
What the best way to model this in Solr or potentially another "nosql" system that can help with this problem. 在Solr或潜在的另一个“ nosql”系统中对此建模的最佳方法是什么,可以解决此问题。
I'm using Solr but I have the opportunity to use another system if I can and if it makes sense. 我正在使用Solr,但是如果可以的话,我有机会使用另一个系统。
EDIT: Solr solution is to slow for Join (Maybe we can try nested). 编辑:Solr解决方案是加入慢(也许我们可以尝试嵌套)。 And the current MySQL solution which uses join tables has over 2 billion rows.
并且当前使用联接表的MySQL解决方案有超过20亿行。
so, you just want to store a mapping between User->Cars, and retrieve the cars based on the user...sounds very simple: 因此,您只想在User-> Cars之间存储映射,并根据用户检索汽车...听起来很简单:
given a user id, you retrieve the 'carsliked' field, and get the car details with a cross collection join 给定用户ID,您将检索“ carsliked”字段,并通过交叉集合联接获取汽车详细信息
You could also use nested object to store each liked car (with all the info about it) inside each user, but is a bit more complex. 您还可以使用嵌套对象将每个喜欢的汽车(以及有关它的所有信息)存储在每个用户内,但是要复杂一些。 As a plus, you don't need the join on the query.
另外,您不需要查询上的联接。
Solr would allow you many more things, for example, given a car, which users do like it? Solr可以让您做更多事情,例如,给定一辆车,哪个用户喜欢呢? Elasticsearch will work exactly the same way (and probably many other tools, given how simple your use case seems).
Elasticsearch将以完全相同的方式工作(考虑到用例看起来多么简单,可能还有许多其他工具)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.