假设我有一个包含产品数据的索引:
productid
productprice
productcategory
productname
用客户价格索引二:
customerid
customerprice
productid
我将如何进行查询以索引 1,其中(如果客户已登录),有一个字段从索引 2 检索匹配值(customerid、productid)?
是否需要索引二,或者是否有更有效的方法来存储/检索客户特定价格?
提前致谢
更新
如果您需要性能“范围”,大约有 7.000 个客户和 200 万个价格。
最佳答案
首先做一些简单的/有效的事情。
1) 解决方案 1/SOLR 索引 Solr 不是数据库,它是搜索引擎,但如果您的价格非常不稳定(变化很大......等等)。最好选择数据库实现。
There is approximately 7.000 customers and 2 million prices, if you need a "scope" on performance. Solr is done to manage a lot of references. Don't be afraid of that, you need to build good indexes, the rest is managed by solr.
尽管如此,如果您想使用 solr,请对这个字段执行一个索引:
- productid
- productprice
- productcategory
- productname
- customerid
- customerprice
2) 我会建议你使用 Redis DB,你的用例并不是真正的搜索引擎。在redis中你会这样存储
product:{productid} => {productprice, productcategory, productname}
product:{productid}:customer:{custumerid} => {customerprice}
Redis 速度极快,可调用并加载到内存中!
关于c# - SOLR/C# - 是否可以查询一个 SOLR 索引,并从另一个索引附加文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44388241/