大家好,我是 Solr 的新手,想完成以下场景(如下),但不确定 Solr 是否能够处理这样的情况:
这个问题很简单,我想建立一个价格比较搜索。有我的理性数据库表:
t_company:
company_id
company_name
t_product:
product_id
product_price
t_company_product:
company_product_id
company_id
product_id
在 Solr 中,我想执行以下搜索 - 获取以最低 TOTAL 价格提供一种或多种特定产品的所有公司(因此,如果您选择螺钉、钉子和石板,我想给出最低总购买价格) .
当我设置我的架构时,我将业务设置为主要实体,并将 product_ids 和 product_prices 设置为两个多值字段。
我可以这样查询吗?我将如何求和?
这是我所有的 XML schema.xml 和 data-config.xml
<document name="companies">
<entity name="company" dataSource="dsCompany"
query="select
newid() as row_id,
company_id,
company_name
from
t_company WITH (NOLOCK)">
<field column="row_id" name="row_id" />
<field column="company_id" name="company_id" />
<field column="company_name" name="company_name" />
<entity name="products" query="select
company_product_id,
product_id,
price
from
t_company_product WITH (NOLOCK)
where
company_id='${company.company_id}'"
dataSource="dsCompany">
<field name="company_product_id" column="company_product_id" />
<field name="product_id" column="product_id" />
<field name="price" column="price" />
</entity>
</entity>
<fields>
<field name="row_id" type="string" indexed="true" stored="true" required="true"/>
<field name="company_id" type="integer" indexed="true" stored="true" required="true" />
<field name="company_name" type="text" indexed="true" stored="true"/>
<field name="service_id" type="integer" indexed="true" stored="true" required="true" />
<field name="price" type="tfloat" indexed="true" stored="true" required="true" />
</fields>
任何反馈将不胜感激!!!